[Mono-list] MySQL and NULL values

Derek Hamilton derek@capweb.com
Fri, 7 Feb 2003 16:04:55 -0800


Sorry to reply to my own post so quickly.  I'm not sure exactly who to send
this to (never worked with open source before) but I found the line of code
that is causing NULL values to fail in the BtyeFX code.

In the datareader.cs page if this:

public bool IsDBNull(int i)
{
     return DBNull.Value == GetValue(i);
}

is changed to

public bool IsDBNull(int i)
{
     return GetValue(i) == null;
}

then the IsDBNull will actually catch NULL values where as before it would
not (at least in my case).  I'm not really sure why the System.DBNull
wouldn't catch this.

Thanks,
Derek Hamilton

----- Original Message -----
From: "Derek Hamilton" <derek@capweb.com>
To: <mono-list@ximian.com>
Sent: Friday, February 07, 2003 3:35 PM
Subject: [Mono-list] MySQL and NULL values


> Hello all,
>
> I am using the ByteFX library for MySQL db access and am experiencing
> trouble with NULL.  I am wondering if this is a MySQL problem (I remember
> something about null handling being a problem in that past) or a
BtyeFX/mono
> problem.
>
> Specifically, if I create a MySQLDataReader and Read() through the results
> where the results all have values it works fine.  If I try reading through
a
> result set with any kind of NULL I get a "Object reference not set to an
> instance of an object."
>
> If I change all the nulls in my db to be an empty string the problem
doesn't
> occur.  I'm just not sure how feasible that is.
>
> Any advice?
>
> Thanks,
> Derek Hamilton
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>