VB.Net syntax for an Access2003 SQL LIKE query?

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?
 
K

Ken Tucker [MVP]

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

felecha

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

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