
July 7th, 2007, 10:41 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 2
Time spent in forums: 29 m 20 sec
Reputation Power: 0
|
|
|
Initial Database Setup
I am looking for a way to create the initial db objects for our application using ADO.net. Currently we have several long .sql scripts that we run through OSQL but I would like to tidy this up. I thought this would be simple using the following sample code but it appears to not allow complex queries i.e. ones with several statements strung together with 'go' between them.
Code:
SqlConnection con = new SqlConnection("Password=;Persist Security Info=True;User ID=sa;Initial Catalog=test;Data Source=SQLServer");
String sqlQuery = File.ReadAllText(@"c:\GenericCRMTables.sql");
SqlCommand cmd = new SqlCommand(sqlQuery, con);
con.Open();
cmd.ExecuteScalar();//I have also tried ExecuteNonQuery
What's the best way to set up these tables and other objects through .net?
I guess we could write a parser that seperates everthing between the 'go's and sends each command seperately.
thanks,
-pat
|