The error code consists of five characters. 00000 means "no error". The values are specified by ANSI SQL and ODBC.
This feature is available for MySQL servers 4.1.1 and newer.
try { MySqlConnection connection = new MySqlConnection("User Id=test; Host=localhost; Port=3306; Database=test"); connection.Open(); MySqlCommand command = new MySqlCommand("insert into dept values (10,'test,'test')", connection); command.ExecuteNonQuery(); command.ExecuteNonQuery(); } catch (MySqlException ex) { Console.WriteLine("Message: " + ex.Message); Console.WriteLine("Code: " + ex.Code.ToString()); Console.WriteLine("SqlState: " + ex.SqlState); }
Try Dim connection As MySqlConnection = New MySqlConnection("User Id=test; Host=localhost; Port=3306; Database=test") connection.Open() Dim Command As MySqlCommand = New MySqlCommand("insert into dept values (10,'test,'test')", connection) Command.ExecuteNonQuery() Command.ExecuteNonQuery() Catch ex As MySqlException Console.WriteLine("Message: " + ex.Message) Console.WriteLine("Code: " + ex.Code.ToString()) Console.WriteLine("SqlState: " + ex.SqlState) End Try
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2