using System; using System.Data; using System.Data.Odbc; class TestClient { static void Main(string[] args) { const string server = "enter mysql server host here"; const string userId = "login goes here"; const string password = "and the password"; const int option = 3; string dsn = "Driver={MySQL ODBC 3.51 Driver}" + ";Option=" + option + ";Server=" + server + ";Uid=" + userId + ";Pwd=" + password + ";Database=TestDb"; string select = "SELECT * FROM testtable"; OdbcDataAdapter oda = new OdbcDataAdapter(select, dsn); OdbcCommandBuilder ocb = new OdbcCommandBuilder(oda); DataSet ds = new DataSet(); oda.Fill(ds); DataRow row1 = ds.Tables[0].Rows[0]; DataRow row2 = ds.Tables[0].Rows[1]; // Testing, testing... printExpected(row1, (Decimal) 10000000000000000000L); printExpected(row2, (Decimal) ulong.MaxValue); // Update something random so .NET will send an update through ODBC. row1["Id"] = 123; // Next code line fails: // ERROR [07006] [MySQL][ODBC3.51 Driver][mysqld-5.0.18-nt-max] // Restricted data type attribute violation(SQL_C_NUMERIC) oda.Update(ds); } static void printExpected(DataRow row, object expected) { // Just a quick test to see if uint64 columns are read ok. object gotten = row["Counter"]; Console.Out.WriteLine("From DB: {0} ==> {1}", gotten.GetType().Name, gotten.ToString()); Console.Out.WriteLine("Expected: {0} ==> {1}", expected.GetType().Name, expected.ToString()); Console.Out.WriteLine(); } }