Reputation: 41
I have c# code that is taking arguments from an xml file and executing commands from a .sql file passed in to the xml.
I have a case statement for different types of connections.
switch (type)
{
case @"type=mysql":
conn = new MySqlConnection(connection);
break;
case @"type=odbc":
conn = new OdbcConnection(connection);
break;
}
When I run using a mySql or sql client it works fine:
MySqlCommand queryCmd = new MySqlCommand(query, con);
queryCmd.ExecuteNonQuery();
but when I switch to an odbc client
OdbcCommand queryCmd = new OdbcCommand(query, con);
queryCmd.ExecuteNonQuery();
I get
"Exception thrown: read access violation. stmt was nullptr." And "System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'"
update: : I tested with a sql server connection and this does execute properly. It fails when using with a MariaDb connection. Also this fails on the execution, not on the connection.
Upvotes: 0
Views: 605
Reputation: 41
What ended up working for me:
Upvotes: 1