dbTalk Databases Forums  

ActiveX Vb Script

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss ActiveX Vb Script in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chinna jambu via SQLMonster.com
 
Posts: n/a

Default ActiveX Vb Script - 02-22-2005 , 09:08 PM






can any one help me with the below script.
I am getting error like
Error code = 0
Error Source = ADODB.recordset
Error Description : operation is not allowed when the object is closed.
error on line 15
Operation is not allowed when the object is closed

*****

Function Main()

Dim cnn, rst,count
set cnn = CreateObject("ADODB.Connection")
set rst = CreateObject("ADODB.Recordset")
cnn.ConnectionString="Provider=SQLOLEDB;Data Source=cpmqsit;Initial
Catalog=HTCtest;User ID = 'SQLDBA';Password='Access!'"
cnn.Open

set rst = cnn.Execute ("insert into properties1 (propertyid)select
propcode
from htcrepr where propcode not in (select propertyid from properties1)
group
by propcode")

While Not rst Is Nothing
If (Not rst.EOF) Then
Debug.Print rst(0)
End If
' Set rst = rst.NextRecordset
Wend


cnn.Close
set cnn = nothing
Main = DTSTaskExecResult_Success
End Function


thanks


Quote:
|
--
Message posted via http://www.sqlmonster.com


Reply With Quote
  #2  
Old   
Frank Matthiesen
 
Posts: n/a

Default Re: ActiveX Vb Script - 02-23-2005 , 05:23 AM






chinna jambu via SQLMonster.com wrote:
Quote:
can any one help me with the below script.
I am getting error like
Error code = 0
Error Source = ADODB.recordset
Error Description : operation is not allowed when the object is
closed. error on line 15
Operation is not allowed when the object is closed

set rst = cnn.Execute ("insert into properties1 (propertyid)select
propcode
from htcrepr where propcode not in (select propertyid from
properties1) group
by propcode")

While Not rst Is Nothing
If (Not rst.EOF) Then
Debug.Print rst(0)
End If
' Set rst = rst.NextRecordset
Wend

chinna,

your sql-statement returns no recordset, because you made an INSERT
Write instead:

<code>
Dim cnn, rst,count
set cnn = CreateObject("ADODB.Connection")

cnn.ConnectionString="Provider=SQLOLEDB;Data Source=cpmqsit;Initial
Catalog=HTCtest;User ID = 'SQLDBA';Password='Access!'"
cnn.Open

cnn.Execute ("insert into properties1 (propertyid)select
propcode
from htcrepr where propcode not in (select propertyid from properties1)
group
by propcode")

cnn.Close
set cnn = nothing
Main = DTSTaskExecResult_Success
End Function
</code>

regards

frank




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.