<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; JS: ошибка при закрытии объекта Recordset]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10059&amp;type=atom" />
	<updated>2014-10-18T15:18:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10059</id>
		<entry>
			<title type="html"><![CDATA[Re: JS: ошибка при закрытии объекта Recordset]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=87482#p87482" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>im2002 пишет:</cite><blockquote><p>вот и непонятно как оно вдруг &quot;само закрылось&quot;...</p></blockquote></div><p><a href="http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms675544(v=vs.85).aspx">Open Method (ADO Recordset)</a>:<br /></p><div class="quotebox"><blockquote><p>…<br />It is not a good idea to use the Source argument of the Open method to perform an action query that does not return records because there is no easy way to determine whether the call succeeded. The Recordset returned by such a query will be closed. To perform a query that does not return records, such as a SQL INSERT statement, call the Execute method of a Command object or the Execute method of a Connection object instead.<br />…</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-10-18T15:18:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=87482#p87482</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JS: ошибка при закрытии объекта Recordset]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=87481#p87481" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Xameleon пишет:</cite><blockquote><p><strong>im2002</strong>, причина в том, что соединение в таком случае уже само закрылось.</p></blockquote></div><p>вот и непонятно как оно вдруг &quot;само закрылось&quot;...</p>]]></content>
			<author>
				<name><![CDATA[im2002]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28063</uri>
			</author>
			<updated>2014-10-18T14:38:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=87481#p87481</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JS: ошибка при закрытии объекта Recordset]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=87449#p87449" />
			<content type="html"><![CDATA[<p><strong>im2002</strong>, причина в том, что соединение в таком случае уже само закрылось. Если Вы не используете данные, возвращённые из запроса, то Вам проще использовать объект <strong>ADODB.Connection</strong> и его метод <strong>Execute</strong>. А возможно, ещё лучше, <strong>ADODB.Command</strong>. В принципе, он может даже дать выигрыш в скорости. Так как в нём можно сразу явно указать:<br />1) к чему вы собираетесь обращаться - процедура / таблица / функция и т.п.<br />2) Тип данных для каждого из переданных параметров.</p><div class="codebox"><pre><code>
var oDbCn = new ActiveXObject(&quot;ADODB.Connection&quot;)
oDbCn.Open(&quot;driver={SQL Server};server=NHMS241\\ITSQL;database=TFD8;Username=sa;PWD=%LcGhjvj%&quot;);
var oDbRs = oDbCn.Execute(&quot;select * from UseVariant&quot;);
WScript.Echo(oDbRs.EOF)
</code></pre></div><p>P.S Кстати для <strong>Recordset</strong> в методе <strong>Open</strong>, <span class="bbu">вторым параметром</span> предпочтительнее использовать созданное и открытое подключение - экземпляр объекта <strong>ADODB.Connect</strong>. Это так же ускоряет работу.</p>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2014-10-17T07:10:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=87449#p87449</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[JS: ошибка при закрытии объекта Recordset]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=87447#p87447" />
			<content type="html"><![CDATA[<p>не могу разобраться почему в таком коде:<br /></p><div class="codebox"><pre><code>var AdoRs = new ActiveXObject(&quot;ADODB.Recordset&quot;);
var sSource =  &quot;INSERT INTO UseVariant VALUES(1, 10, 100)&quot;;    
var sConnect = &quot;driver={SQL Server};server=NHMS241\\ITSQL;database=TFD8;Username=sa;PWD=%LcGhjvj%&quot;;
try
    {
    AdoRs.open(sSource, sConnect);            
    WScript.Echo(&quot;Данные внесены в таблицу&quot;);
    AdoRs.close();                              // попытка закрытия объекта Recordset всегда вызывает ошибку
                                                                      // и выполнение перейдёт в catch
    }
catch(err)
    {
    WScript.Echo(&quot;Ошибка открытия БД\n&quot; + err.message);
    WScript.Quit();                    
    }</code></pre></div><p>инструкция AdoRs.close() вызывает переход в catch с ошибкой: &quot;Операция не допускается, если объект закрыт&quot;???<br />Данные в таблицу при этом вносятся... Внесли данные - закрыли объект Recordset... я так понимаю.<br />Если вместо запроса на изменение данных поставить запрос на выборку, к примеру:<br /></p><div class="codebox"><pre><code>var sSource =  &quot;select * from UseVariant&quot;;</code></pre></div><p>то никакой ошибки уже не возникает в&nbsp; AdoRs.close()</p>]]></content>
			<author>
				<name><![CDATA[im2002]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28063</uri>
			</author>
			<updated>2014-10-17T05:29:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=87447#p87447</id>
		</entry>
</feed>
