Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Running sql script files from VB

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-11-11 : 08:04:54
Arun writes "Hi there,

I want to know how i can run script file from VB, just like the way we do in Query analyzer.

thanx

Arun"

tuenty
Constraint Violating Yak Guru

278 Posts

Posted - 2004-11-11 : 09:48:54
you have to set an adodb.connection open it and then execute the statement
dim conn as new adodb.connection
dim sqlStatement as string
sqlstatement= "Update tblWhatever Set field1 = 1 Where field2 =3; Update tblX set field1 = 0 " _
& "where fieldX=1"
conn.open connStr 'this a global variable containing the connection string
conn.execute sqlstatement
conn.close
set conn= nothing

but if you want to use the output of the sql statements then you must also use a recordset

for more info search on the MSDN for ADO connections, recordsets and connection strings

*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
A candle loses nothing by lighting another candle
Go to Top of Page
   

- Advertisement -