Page 1 of 1

DBNull.Value not supportet?

Posted: Tue 26 Jan 2010 14:35
by Zero-G.
Hey

I use dotConnect for mySQL with the following code:

Code: Select all

Dim Groesse As Object = IIf(cmbGrösse.Value Is Nothing, DBNull.Value, cmbGrösse.Value)
            Dim Farbe As Object = IIf(cmbFarbe.Value Is Nothing, DBNull.Value, cmbFarbe.Value)
            Dim qArtikel = (From Query In LinqProvider.GetProvider.Artikelstamms _
                           Where Query.Invnr = Convert.ToString(cmbInvNr.Value) And _
                           Query.Lieferant = Convert.ToInt64(cmbLieferant.Value) And _
                           Query.Artikelnr = Convert.ToString(cmbArtNummer.Value) And _
                           Query.Groesse = Groesse And _
                           Query.Farbe = Farbe).Single
When either cmbFarbe.Value or cmbGroesse.Value = NOTHING, then I get an error, that
Method 'CompareObjectEqual' has no supported translation to SQL.
I also tried to set cmbGroesse.Value to "" when it is nothing, but "" is not equal to NULL

Any tip do this?

Posted: Tue 26 Jan 2010 17:26
by AndreyR
The IIf operator is not supported yet. I will let you know as soon as it is implemented.

Posted: Tue 26 Jan 2010 17:33
by Zero-G.
That wasn't the problem
I found out this moment.
Using this code:
Dim Groesse As Object = IIf(cmbGrösse.Value Is Nothing, DBNull.Value, cmbGrösse.Value)
Dim Farbe As Object = IIf(cmbFarbe.Value Is Nothing, DBNull.Value, cmbFarbe.Value)
Dim qArtikel = (From Query In LinqProvider.GetProvider.Artikelstamms _
Where Query.Invnr = Convert.ToString(cmbInvNr.Value) And _
Query.Lieferant = Convert.ToInt64(cmbLieferant.Value) And _
Query.Artikelnr = Convert.ToString(cmbArtNummer.Value) And _
Query.Groesse.Equals(Groesse) And _
Query.Farbe.Equals(Farbe)).Single
is working as I want