<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Ошибка ADODB.Recordset: Аргументы имеют неверный тип]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7967&amp;type=atom" />
	<updated>2013-02-28T06:51:05Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7967</id>
		<entry>
			<title type="html"><![CDATA[Re: Ошибка ADODB.Recordset: Аргументы имеют неверный тип]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=69820#p69820" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>RS1.Open Cmd_string1, objSQLServer, adOpenKeyset, adLockOptimistic, adCmdText</code></pre></div><p>Экспериментально не проверял, но судя по документации...<br /><a href="http://msdn.microsoft.com/en-US/library/dd785923(v=bts.10).aspx">Open Method on a Recordset Object (ADO)</a><br /></p><div class="quotebox"><blockquote><p>recordset.Open <strong>Source</strong>, ActiveConnection, CursorType, LockType, Options</p><p><strong>Source</strong><br />This optional parameter specifies a Variant that evaluates to a <span class="bbu">valid Command object variable name</span> or a valid string specifying the command text specific to the Microsoft OLE DB Provider for AS/400 and VSAM to open a data file on the host.</p></blockquote></div><p>Если мой английский меня не подводит, то Source это не переменная типа string, а объект типа ADODB.Command. Скорее всего это и есть причина ошибки - &quot;Аргументы имеют неверный тип&quot;.</p><p>Соответственно нужно перед открытием рекордсета добавить что-то такое:<br /></p><div class="codebox"><pre><code>
Dim oCommand
Set oCommand = CreateObject(&quot;ADODB.Command&quot;)
oCommand.ActiveConnection = objSQLServer
oCommand.CommandText = &quot;SELECT ENTRY, AttributeName, AttributeValue   FROM ComponentAttribute WHERE AttributeName=&#039;D2K_Dev_Sub_Class&#039; OR AttributeName=&#039;D2K_1C_Code&#039; OR AttributeName=&#039;Name_1C&#039; OR AttributeName=&#039;Naimenovanie_V4&#039; OR AttributeName=&#039;Marka&#039; OR AttributeName=&#039;Block_E2&#039; OR AttributeName=&#039;Complect&#039; OR AttributeName=&#039;D2K_Status&#039; OR AttributeName=&#039;SubSystem&#039; ORDER BY ENTRY&quot;
oCommand.CommandType = adCmdText
</code></pre></div><p>И при открытии рекордсета передавать туда объект:<br /></p><div class="codebox"><pre><code>RS1.Open oCommand, objSQLServer, adOpenKeyset, adLockOptimistic, adCmdText</code></pre></div>]]></content>
			<author>
				<name><![CDATA[BeS Yara]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25643</uri>
			</author>
			<updated>2013-02-28T06:51:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=69820#p69820</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Ошибка ADODB.Recordset: Аргументы имеют неверный тип]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68405#p68405" />
			<content type="html"><![CDATA[<p>Пытаюсь получить из базы SQL данные для того чтобы потом их выводить в Excel. Я получаю Recordset из одной таблицы базы, а потом из другой таблицы той же базы. Проблема в том, что таблицы устроены по-разному и первую таблицу я беру как есть, а во второй мне нужно искать соответствующие записи. Метод Recordset.Find не работает, если Recordset получен с помощью Connection.Execute. И я пытаюсь создать второй Recordset с помощью Recordset.Open:</p><div class="codebox"><pre><code>Set objSQLServer = CreateObject(&quot;ADODB.Connection&quot;)                
Set RS1 = CreateObject(&quot;ADODB.Recordset&quot;)                                        
Conn_string = &quot;Driver={SQL Server};Server=DB1;database=E3v2011;Trusted_Connection=true&quot;  

objSQLServer.Open Conn_string
                                            
Cmd_string = &quot;SELECT ENTRY, Version, VersionText, LASTUPDT, Class, Description, Supplier, ArticleNumber, ENTRYTYP, DeviceLetterCode, Flags  FROM ComponentData ORDER BY ENTRY&quot;        

Set RS = objSQLServer.Execute (Cmd_string, adCmdText) 

Cmd_string1 = &quot;SELECT ENTRY, AttributeName, AttributeValue   FROM ComponentAttribute WHERE AttributeName=&#039;D2K_Dev_Sub_Class&#039; OR AttributeName=&#039;D2K_1C_Code&#039; OR AttributeName=&#039;Name_1C&#039; OR AttributeName=&#039;Naimenovanie_V4&#039; OR AttributeName=&#039;Marka&#039; OR AttributeName=&#039;Block_E2&#039; OR AttributeName=&#039;Complect&#039; OR AttributeName=&#039;D2K_Status&#039; OR AttributeName=&#039;SubSystem&#039; ORDER BY ENTRY&quot;

RS1.Open Cmd_string1, objSQLServer, adOpenKeyset, adLockOptimistic, adCmdText</code></pre></div><p>В результате появляется ошибка: <br />Error: Аргументы имеют неверный тип, выходят за пределы допустимого диапазона или вступают в конфликт друг с другом.<br />Code: 800A0BB9<br />Source: ADODB.Recordset<br />System: Указанный драйвер принтера занят.</p><p>При этом вариант с Connection.Execute для обеих таблиц работает:</p><div class="codebox"><pre><code>Set objSQLServer = CreateObject(&quot;ADODB.Connection&quot;)                

Conn_string = &quot;Driver={SQL Server};Server=DB1;database=E3v2011;Trusted_Connection=true&quot;  

objSQLServer.Open Conn_string
                                            
Cmd_string = &quot;SELECT ENTRY, Version, VersionText, LASTUPDT, Class, Description, Supplier, ArticleNumber, ENTRYTYP, DeviceLetterCode, Flags  FROM ComponentData ORDER BY ENTRY&quot;        

Set RS = objSQLServer.Execute (Cmd_string, adCmdText) 

Cmd_string1 = &quot;SELECT ENTRY, AttributeName, AttributeValue   FROM ComponentAttribute WHERE AttributeName=&#039;D2K_Dev_Sub_Class&#039; OR AttributeName=&#039;D2K_1C_Code&#039; OR AttributeName=&#039;Name_1C&#039; OR AttributeName=&#039;Naimenovanie_V4&#039; OR AttributeName=&#039;Marka&#039; OR AttributeName=&#039;Block_E2&#039; OR AttributeName=&#039;Complect&#039; OR AttributeName=&#039;D2K_Status&#039; OR AttributeName=&#039;SubSystem&#039; ORDER BY ENTRY&quot;

Set RS1 = objSQLServer.Execute (Cmd_string1, adCmdText) </code></pre></div><p>Что я не так делаю в первом варианте?</p>]]></content>
			<author>
				<name><![CDATA[Carbon kid]]></name>
			</author>
			<updated>2013-01-11T13:26:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68405#p68405</id>
		</entry>
</feed>
