I'm having an open OdbcConnection, I'm trying to write to a database using OdbcCommand and I would like to verify if the database i read-only before inserting data.
I can use try and catch, but I hope there is a better solution.
Thanks in advance.
OdbcConnection con = new OdbcConnection("DSN=SERVER1;UID=User;PWD=User");
try
{
con.Open();
OdbcCommand cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO table1 (NAME, AGE) VALUES ('Test', 100)";
cmd.ExecuteNonQuery();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
con.Close()
}
Here's the output when the database is read-only:
ERROR [HY000] SOLID Database Error 10013: Transaction is read-only