I have a mysql 5.0 database on my machine. I have a table whose primary keys are given the type BIGINT(20). I am using ODBC via a DSN that uses the MySql ODBC driver to connect to mysql.
When I retrieve this data from the database and get it into C#, the datatype is coming across as a DECIMAL. I thought the C# equivalent of a BIGINT datatype was one of the following: long, Int32, Int64. None of these conversions seem to work.
Obviously on my id fields, I do not want decimals. Anyone have some ideas?
public static List<Message> getMessages()
List<Message> messages = new List<Message>();
OdbcConnection MyConn = DBConnection.getDBConnection();
OdbcDataReader result = null;
OdbcCommand myCmd = new OdbcCommand();
myCmd.Connection = MyConn;
myCmd.CommandText = mySqlQueries.getAllMessages;
result = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
Message message = new Message();
String t = result["messageid"].GetType().ToString(); //VALUE IS DECIMAL
message.MessageId = result.GetInt64(result.GetOrdinal("messageid")); // THIS LINE