Interrogating mySQL datatypes with ADO.NET

M

Mark Rae

Hi,

Interrogating the DataType property of a DataColumn object where the
underlying column in a mySQL table is CHAR, VARCHAR or TEXT returns
System.String for each. Is there a method to differentiate these underlying
datatypes and, if so, to interrogate the column length so that it will
return me, say, VARCHAR(20) instead of just System.String?

Any assistance gratefully received.

Best regards,

Mark Rae
 
S

Sahil Malik

I am not a MySql expert, but seems like this level of detail isn't built
into the provider you are using. You could verify that by decompiling it
using reflector. Worst case, you might want to write up your own schema
query mechanisms.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
F

Frans Bouma [C# MVP]

Mark said:
Core Lab MySQLDirect .NET Data Provider 2.30

That's an oldie :) They're at 2.70.1 at the moment.

To answer your original question, no, once the db type is converted to
the .net type, you're stuck with the .NET type, as the db type is not
that interesting (in theory).

If you want to know the db type, you can always use the describe table
command of mysql, or use the trick with the command builder (create a
command using the command builder object, and check which type is
created for the parameters for the various fields)

Frans.
 
M

Mark Rae

That's an oldie :) They're at 2.70.1 at the moment.

To answer your original question, no, once the db type is converted to the
.net type, you're stuck with the .NET type, as the db type is not that
interesting (in theory).

If you want to know the db type, you can always use the describe table
command of mysql, or use the trick with the command builder (create a
command using the command builder object, and check which type is created
for the parameters for the various fields)

OK - thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top