Parameter it doesn't work (for me) II

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
 
S

Stephany Young

As you were told last time you posted this question, the wildcard for like
in ADO and ADO.NET is %, not *.
 
S

Stephany Young

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.
 
F

Fia

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top