<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; JS: ошибка при закрытии объекта Recordset]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=10059</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10059&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «JS: ошибка при закрытии объекта Recordset».]]></description>
		<lastBuildDate>Sat, 18 Oct 2014 15:18:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: JS: ошибка при закрытии объекта Recordset]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87482#p87482</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Sat, 18 Oct 2014 15:18:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87482#p87482</guid>
		</item>
		<item>
			<title><![CDATA[Re: JS: ошибка при закрытии объекта Recordset]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87481#p87481</link>
			<description><![CDATA[<div class="quotebox"><cite>Xameleon пишет:</cite><blockquote><p><strong>im2002</strong>, причина в том, что соединение в таком случае уже само закрылось.</p></blockquote></div><p>вот и непонятно как оно вдруг &quot;само закрылось&quot;...</p>]]></description>
			<author><![CDATA[null@example.com (im2002)]]></author>
			<pubDate>Sat, 18 Oct 2014 14:38:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87481#p87481</guid>
		</item>
		<item>
			<title><![CDATA[Re: JS: ошибка при закрытии объекта Recordset]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87449#p87449</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Xameleon)]]></author>
			<pubDate>Fri, 17 Oct 2014 07:10:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87449#p87449</guid>
		</item>
		<item>
			<title><![CDATA[JS: ошибка при закрытии объекта Recordset]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87447#p87447</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (im2002)]]></author>
			<pubDate>Fri, 17 Oct 2014 05:29:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87447#p87447</guid>
		</item>
	</channel>
</rss>
