dbTalk Databases Forums  

VBA to VB in DTS ActiveX

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


Discuss VBA to VB in DTS ActiveX in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Stephen Lonsdale
 
Posts: n/a

Default VBA to VB in DTS ActiveX - 08-10-2006 , 11:49 AM






I am using the VB code below in MS Access to insert a record in a SQL table.
The code works fine.

I now want to move this code to an ActiveX script in DTS (SQL 2000) but get
errors when I Parse the code. Can anyone please expain what I'm doing wrong?

many thanks

Stephen Lonsdale


'recordset and connection variables
Dim Cnxn As ADODB.Connection
Dim rstTest As ADODB.Recordset
Dim strCnxn As String
Dim strSQL As String

' Open a connection
Set Cnxn = New ADODB.Connection
strCnxn = "Provider=SQLOLEDB.1;Data Source=(local); Initial
Catalog=test_db;user id = 'sa';password='test_pwd'"

Cnxn.Open strCnxn

Set rstTest = New ADODB.Recordset
strSQL = "sys__event_tracker"
rstTest.Open strSQL, strCnxn, adOpenKeyset, adLockOptimistic, adCmdTable


rstTest.AddNew
rstTest!event_category = "test message"
rstTest.Update

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: VBA to VB in DTS ActiveX - 08-11-2006 , 03:45 AM






Hello Stephen,

The conversion would not be that hard to do but the question I would have
is why?

In DTS you have a Connection type for Access and a Connection type for SQL
Server. These should serve you perfectly well unless you have some overwhelming
requirements of the insert.


Allan




Quote:
I am using the VB code below in MS Access to insert a record in a SQL
table. The code works fine.

I now want to move this code to an ActiveX script in DTS (SQL 2000)
but get errors when I Parse the code. Can anyone please expain what
I'm doing wrong?

many thanks

Stephen Lonsdale

'recordset and connection variables
Dim Cnxn As ADODB.Connection
Dim rstTest As ADODB.Recordset
Dim strCnxn As String
Dim strSQL As String
' Open a connection
Set Cnxn = New ADODB.Connection
strCnxn = "Provider=SQLOLEDB.1;Data Source=(local); Initial
Catalog=test_db;user id = 'sa';password='test_pwd'"
Cnxn.Open strCnxn

Set rstTest = New ADODB.Recordset
strSQL = "sys__event_tracker"
rstTest.Open strSQL, strCnxn, adOpenKeyset, adLockOptimistic,
adCmdTable
rstTest.AddNew
rstTest!event_category = "test message"
rstTest.Update



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.