Sunday, August 24, 2008

Issues with IsDBNull and MySQL Varchar Fields

This one is bizarre - I am not sure if the issue lies in with the .NET framework or MySQL.

Opening a DataReader on an Odbc connection type in VB.NET allows for the verification of null fields with the .IsDBNull function. However, in one instance, I was absolutely certain that a MySQL field was null (I had just created it), yet I kept getting a .NET error in the program when I tried to verify the null status. I checked and checked and tried many different things. I was using a VARCHAR(45) field and I noticed that most of the DB fields used were VARCHAR(250). Hence, I took a shot in the dark and changed the field to VARCHAR(250). The problems went away.

I still am not sure if this is a .NET or a MySQL error, but it was frustrating and bizarre to say the least.

No comments: