Is it possible to run an entire SQL Script file ( say TestDB.SQL ) through VB 2008 ? If yes then how?
Printable View
Is it possible to run an entire SQL Script file ( say TestDB.SQL ) through VB 2008 ? If yes then how?
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.
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.
This is for VB 2005 but im sure it could be adapted for VB 2008Quote:
Originally Posted by Soumit
http://www.vbforums.com/showthread.php?t=521111