VB.Net syntax for an Access2003 SQL LIKE query?

  • Thread starter Thread starter felecha
  • Start date Start date
F

felecha

Puzzled - I have a fairly simple query against an Access database that
wants to eliminate the records in the table where the DeviceType is
either MasterStation1 or MasterStation2 or ....

in other words, I want the records that do not involve the Master
Stations in our system.

So, I expect to just write

Select * from Device where DeviceType not LIKE '*MasterStation*'

That works fine in a direct query from inside Access's own Query tool.
But calling it from VB.Net with an ADO.Net DataAdapter does not.
All the Master Station records appear in the resultset. I've tried
it with an OledbCommand instead, I've tried many different variations
of the syntax, etc.

Any clue?
 
Hi,

Use % instead of *

Ken
------------------
felecha said:
Puzzled - I have a fairly simple query against an Access database that
wants to eliminate the records in the table where the DeviceType is
either MasterStation1 or MasterStation2 or ....

in other words, I want the records that do not involve the Master
Stations in our system.

So, I expect to just write

Select * from Device where DeviceType not LIKE '*MasterStation*'

That works fine in a direct query from inside Access's own Query tool.
But calling it from VB.Net with an ADO.Net DataAdapter does not.
All the Master Station records appear in the resultset. I've tried
it with an OledbCommand instead, I've tried many different variations
of the syntax, etc.

Any clue?
 
Thanks

That is so interesting.

In the Access environment, * works and % doesn't.

From VB.Net, % works and * doesn't.

I would think that when you tell VB.Net what provider you're going to
use in your ConnectionString property, it would know how to talk with
it. My provider is very specifically

"Provider=Microsoft.Jet.OLEDB.4.0;"

But hey, as my professor used to say, "Working is good."
 
Back
Top