Parameter it doesn't work (for me) II

  • Thread starter Thread starter Fia
  • Start date Start date
F

Fia

Hi again
I tried the code below and know the CommandText looks like it should from
the Trace,
but I still don't get any records.
When I'm running the SQL statement in the Access database I get records.

sökaOrdCom = New OleDbCommand("Select * from kött where köttid Like " & "'"
& PubStr & "*'", DBConn)
sökaOrdRead = sökaOrdCom.ExecuteReader
Trace.WriteLine(sökaOrdCom.CommandText)

Do While sökaOrdRead.Read
recCount += 1 'this code never happens
Loop

I don't get this, please help me.

Fia
 
As you were told last time you posted this question, the wildcard for like
in ADO and ADO.NET is %, not *.
 
From the page you indicated:

<quote>
Note The % and _ (underscore) wildcard characters should be used only
through the Jet OLE DB provider and ActiveX® Data Objects (ADO) code. They
will be treated as literal characters if they are used though the Access SQL
View user interface or Data Access Objects (DAO) code.
</quote>

There is a very good reason for this and that is because ADO (both flavours)
specifies % and _ as the wildcard characters in SQL statements. * and ? just
don't work. Whatever the rights, wrongs or indifferences, it is a fact of
life.
 
Thank's now it works!!!

Fia
Stephany Young said:
From the page you indicated:

<quote>
Note The % and _ (underscore) wildcard characters should be used only
through the Jet OLE DB provider and ActiveX® Data Objects (ADO) code. They
will be treated as literal characters if they are used though the Access SQL
View user interface or Data Access Objects (DAO) code.
</quote>

There is a very good reason for this and that is because ADO (both flavours)
specifies % and _ as the wildcard characters in SQL statements. * and ? just
don't work. Whatever the rights, wrongs or indifferences, it is a fact of
life.
 
Back
Top