query returns rows from access but not from .Net

K

Kstro

Hi,
This might be a .Net question but I thought I'd ask anyway.
The following query returns 46 rows if run as an access query but no rows if
the same SQL string is used form within VB.Net.
Go figure...I've spent 2 hours on this.

Any help?
Thanks.

From ACCESS:
SELECT instrSec, AssignNAME, ItemName, FullName, CMP_EOW FROM 032Portfolios
, MMLBenchMarks where AssignNAME = ItemName GROUP BY instrSec, AssignNAME,
ItemName, FullName, CMP_EOW HAVING (((MMLBenchMarks.CMP_EOW)=7 Or
(MMLBenchMarks.CMP_EOW)=6)) and instrSec like('*CMP*') order by FullName

From .Net:

Dim strSqlCMP As String
strSqlCMP = "SELECT instrSec, AssignNAME, ItemName, FullName, CMP_EOW FROM
032Portfolios , MMLBenchMarks where AssignNAME = ItemName GROUP BY instrSec,
AssignNAME, ItemName, FullName, CMP_EOW HAVING (((MMLBenchMarks.CMP_EOW)=7 Or
(MMLBenchMarks.CMP_EOW)=6)) and instrSec like('*CMP*') order by FullName"
Dim objCMP As New OleDbDataAdapter(strSqlCMP, conn)
objCMP.Fill(ds, "ds_OnTimeCMPNames")
 
D

david epsom dot com dot au

Access/Jet supports two different SQL dialects. You are looking
at the dialect used by default in Access.

In ADO.Net, you should use C wildcards instead of MSDOS wildcards,
ie % instead of * in your SQL.

(david)
 
B

Brendan Reynolds

Use '%' instead of '*' as the wildcard character when executing JET queries
via ADO.NET or ADO 'classic'.
 
K

Kstro

Thank you!

david epsom dot com dot au said:
Access/Jet supports two different SQL dialects. You are looking
at the dialect used by default in Access.

In ADO.Net, you should use C wildcards instead of MSDOS wildcards,
ie % instead of * in your SQL.

(david)
 

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