dbTalk Databases Forums  

How to read from a SQL table & write to a SQL table from VB Script

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


Discuss How to read from a SQL table & write to a SQL table from VB Script in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Karen Middleton
 
Posts: n/a

Default How to read from a SQL table & write to a SQL table from VB Script - 10-20-2004 , 02:23 AM






I have several scenarios whereby within a ActiveX script VB task
script I want to open one of the SQL connections defined in the
package and read from a table in the connection and also I want to be
able to take a value and update into the SQL table.

Can you kindly share the VB script code to read and insert data into a
SQL table preferably if it can use the existing connection.

Thanks
Karen

Reply With Quote
  #2  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: How to read from a SQL table & write to a SQL table from VB Script - 10-20-2004 , 10:23 AM






You can use ADO in VBScript - something along the lines of:
Dim cnn, rst
set cnn = CreateObject("ADODB.Connection")
set rst = CreateObject("ADODB.Recordset")
cnn.ConnectionString="Provider=SQLOLEDB;Data Source=(local);Integrated
Security=SSPI;Initial Catalog=YourDB"
cnn.Open
set rst = cnn.Execute ("Your SQL statement")
<do whatever you need to do>

cnn.Close
set cnn = nothing

-Sue

On 20 Oct 2004 00:23:08 -0700, karenmiddleol (AT) yahoo (DOT) com (Karen
Middleton) wrote:

Quote:
I have several scenarios whereby within a ActiveX script VB task
script I want to open one of the SQL connections defined in the
package and read from a table in the connection and also I want to be
able to take a value and update into the SQL table.

Can you kindly share the VB script code to read and insert data into a
SQL table preferably if it can use the existing connection.

Thanks
Karen


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.