Page 1 of 1
Where are the unsigned numeric types ? How do I use them?
Posted: Wed 14 Feb 2007 07:08
by cesarvegamx
I have a database with an unsigned integer column.
But, in the enumeration of MySqlType, I don't see any of the unsigned types.
In order to perform parameterized queries, which type am I supposed to use to create the parameter ?
Posted: Thu 15 Feb 2007 07:36
by Alexey
You should use CoreLab.MySql.MySqlType.Int type. If you pass negative value to the query, it will be converted to zero.
Posted: Fri 16 Feb 2007 22:02
by cesarvegamx
Really?, welll, my code returns me an error, when I do that:
An exception of type 'System.InvalidCastException' occurred in CoreLab.Data.dll but was not handled in user code
Additional information: Cannot convert parameter value of type 'System.UInt32' to MySQL type 'MySqlType.Int'.
Code: Select all
uint unsig = 4000000000;
MySqlParameter myp = new MySqlParameter("_UInt32Col", MySqlType.Int);
myp.Value = unsig;
comm.Parameters.Add(myp);
This is the first time I'm trying to use a data type not directly supported in the DbType enumeration.
I'd appreciate a snippet.
Posted: Mon 19 Feb 2007 09:09
by Alexey
This happened because you used boundary value. I suggest you not using MySqlType enumeration at all:
Code: Select all
uint unsig = 4000000000;
MySqlParameter myp = new MySqlParameter("_UInt32Col", unsig);
comm.Parameters.Add(myp);