|
-
Jun 7th, 2008, 05:17 AM
#1
Thread Starter
Junior Member
[2008] Running a SQL Script File
Is it possible to run an entire SQL Script file ( say TestDB.SQL ) through VB 2008 ? If yes then how?
-
Jun 7th, 2008, 05:25 AM
#2
Re: [2008] Running a SQL Script File
Yes, you can. Read the the contents of the file in a variable and pass it to ExecuteNonQuery method of the command object like normal query.
-
Jun 7th, 2008, 06:58 AM
#3
Re: [2008] Running a SQL Script File
It depends what you mean by "run". If you mean mimic what would happen if you double-clicked it in Windows Explorer then, just as for any other type of file, you should pass it to Process.Start().
If you mean execute its contents within your VB app then, as Deepak Sakpal suggests, you should read it as a text file and then execute it as you would any other inline SQL. That said, you may want to use ExecuteReader rather than ExecuteNonQuery. That way you have access to any result sets returned by the script.
-
Jun 7th, 2008, 08:53 AM
#4
PowerPoster
Re: [2008] Running a SQL Script File
 Originally Posted by Soumit
Is it possible to run an entire SQL Script file ( say TestDB.SQL ) through VB 2008 ? If yes then how?
This is for VB 2005 but im sure it could be adapted for VB 2008
http://www.vbforums.com/showthread.php?t=521111
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|