Page 1 of 1

Like Operator & equals does not work

Posted: Sat 04 Dec 2010 14:04
by Zero-G.
Hey
Using your latest Components for VB.NET (LinQConnect v6)

When I run the following code:

Code: Select all

 myArtikel = From query In _
                    GetDataContext.Artikelstamms Where _
                    Devart.Data.Linq.SqlMethods.Like(query.Invnr, cmbInvNr.Value) And _
                    query.Lieferant = cmbLieferant.Value And _
                    Devart.Data.Linq.SqlMethods.Like(query.Artikelnr, IIf(txtArtNummer.Text.Length > 0, txtArtNummer.Text, "%")) And _
                    Devart.Data.Linq.SqlMethods.Like(query.Groesse, IIf(txtGroesse.Text.Length > 0, txtGroesse.Text, "%")) And _
                    Devart.Data.Linq.SqlMethods.Like(query.Farbe, IIf(txtFarbe.Text.Length > 0, txtFarbe.Text, "%")) And _
                    Devart.Data.Linq.SqlMethods.Like(query.Artbez, IIf(txtArtBeschreibung.Text.Length > 0, txtArtBeschreibung.Text, "%"))
Then I get the following error: (translated from the german version)
The object of type "Devart.Data.Linq.DataQuery`1[VOPT.VOptNeuContext.Artikelstamm]" can not be cast into Typ "VOPT.VOptNeuContext.Artikelstamm"

query.Lieferant is a Bigint field. - So i can't use the like operator. When I delete the query.Lieferant query, then everything works fine.

THX

Posted: Mon 06 Dec 2010 18:10
by StanislavK
Please check the definition of the MyArtikel variable. Such problem may occur, e.g., if MyArtikel was declared without the type specified (i.e., 'Dim MyArtikel') and was later assigned a value of the VOPT.VOptNeuContext.Artikelstamm type. In this case, MyArtikel is actually a VOptNeuContext.Artikelstamm instance, but is treated as DataQuery, causing a type mismatch.

If this is not the case, please see the test project. I've sent it in a letter, please check that it was not blocked by your mail filter. Please specify what should be changed in the sample to reproduce the problem, or send us your test project.