Where are the unsigned numeric types ? How do I use them?

Where are the unsigned numeric types ? How do I use them?

Postby cesarvegamx » Wed 14 Feb 2007 07:08

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 ?
cesarvegamx
 
Posts: 37
Joined: Tue 30 Jan 2007 07:43

Postby Alexey » Thu 15 Feb 2007 07:36

You should use CoreLab.MySql.MySqlType.Int type. If you pass negative value to the query, it will be converted to zero.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby cesarvegamx » Fri 16 Feb 2007 22:02

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.
cesarvegamx
 
Posts: 37
Joined: Tue 30 Jan 2007 07:43

Postby Alexey » Mon 19 Feb 2007 09:09

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);
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for MySQL