Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

execute SQL procedure from VB

Status
Not open for further replies.

smcmanus

Technical User
Aug 1, 2001
25
CA
Wondering how to execute an SQL procedure from a VB form. For example I have a text file name "something.sql". How would I execute this script command from VB to dump data into my database.

Thanks for your help
 
I am not aware of a method to run a script file within Visual Basic, but there might be one. Instead you can create a string variable set to the sql statement and then execute it either from your connection or command object. The example below is for a command object.

Dim objCommand as ADODB.Command
Dim strSQL as String

Set objCommand = New ADODB.Command
strSQL = "YourSQLStatement"

objCommand.CommandType = adCmdText
objCommand.ActiveConnection = YourConnectionObjectVariable
objCommand.CommandText = strSQL

objCommand.Execute strSQL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top