Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Whilst building an 'custom action' to install a database, I encountered a SqlException ("Incorrect syntax near...") when calling ExecuteNonQuery(). To solve the problem process sql commands separately (using 'GO' as a delimiter). Thankfully parsing the ".sql" file into commands is fairly straight forward:
string[] commands = sql.Split(
new string[]{"GO\r\n", "GO ", "GO\t"}, StringSplitOptions.RemoveEmptyEntries );
foreach (string c in commands)
{
command = new SqlCommand(c, masterConnection);
command.ExecuteNonQuery();
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
masterConnection.Close();
}
}
Comments
Anonymous
February 26, 2008
PingBack from http://www.biosensorab.org/2008/02/26/incorrect-syntax-near-go-sqlcommandexecutenonquery/Anonymous
February 26, 2008
Whilst building an 'custom action' to install a database , I encountered a SqlException ("Incorrect