I'm getting ready to deploy my new app and am having a hard time getting the database deployed.
I was hoping to "generate scripts" from within MSSQl 2008R2 and deploy them back using C#. I can use the created script within MSSQL to create the DB but it won't allow me to use the same script within C#.
How I'm doing it...
I created a .TXT file wtih the DB script in the project then loading that into a string.
_assembly = Assembly.GetExecutingAssembly();
_textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("SP.DBCreate.txt"));
string szQuery = _textStreamReader.ReadToEnd();
using (OleDbConnection aConnection = new OleDbConnection("Provider=SQLNCLI10;Server=localhost;Database=Master;Uid=sa;pwd=mypass"))
using (OleDbCommand dbCommand = new OleDbCommand(szQuery, aConnection))
catch (OleDbException e)
string szMsg = "CheckSQL/CreateTables:" + e.Errors.Message;
I'm getting an error/exception on the db call...
"Incorrect syntax near 'GO'"...
When I did the create scripts it put in "GO"'s after each of the SQL lines.
Any idea what's going on or how I can get this to work?