Home All Groups Group Topic Archive Search About

Parameter it doesn't work (for me) II

Author
5 Apr 2005 8:15 AM
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

Author
5 Apr 2005 8:21 AM
Cor Ligthert
No problem just to keep it in one thread
Author
5 Apr 2005 8:28 AM
Stephany Young
As you were told last time you posted this question, the wildcard for like
in ADO and ADO.NET is %, not *.


Show quoteHide quote
"Fia" <fiao***@telia.com> wrote in message
news:%2309jVdbOFHA.3444@tk2msftngp13.phx.gbl...
> 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
>
>
Author
5 Apr 2005 8:58 AM
Cor Ligthert
> As you were told last time you posted this question, the wildcard for like
> in ADO and ADO.NET is %, not *.
>
What has AdoNet to do with a select string?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp

Thanks for posting in this thread while there is an earlier one with the
same message by the way.

Cor
Author
5 Apr 2005 9:57 AM
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.


Show quoteHide quote
"Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
news:eQcW52bOFHA.4028@tk2msftngp13.phx.gbl...
>> As you were told last time you posted this question, the wildcard for
>> like in ADO and ADO.NET is %, not *.
>>
> What has AdoNet to do with a select string?
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp
>
> Thanks for posting in this thread while there is an earlier one with the
> same message by the way.
>
> Cor
>
Author
5 Apr 2005 10:35 AM
Fia
Thank's now it works!!!

Fia
Show quoteHide quote
"Stephany Young" <noone@localhost> skrev i meddelandet
news:%23vEk%23XcOFHA.3668@TK2MSFTNGP14.phx.gbl...
> 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.
>
>
> "Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
> news:eQcW52bOFHA.4028@tk2msftngp13.phx.gbl...
> >> As you were told last time you posted this question, the wildcard for
> >> like in ADO and ADO.NET is %, not *.
> >>
> > What has AdoNet to do with a select string?
> >
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp
Show quoteHide quote
> >
> > Thanks for posting in this thread while there is an earlier one with the
> > same message by the way.
> >
> > Cor
> >
>
>