Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query does not return data in VB.Net

Status
Not open for further replies.

BobWman

Programmer
Jan 7, 2002
169
US
I have the following query that correctly returns 53 rows when I run it in Access.

Select L.ID, L.TracsNumber, P.OldProjectNumber, P.ADOTPrefix, L.TestHole, L.UpperDepth, L.LowerDepth, L.SamplePhase As Phase, Format(L.DateSampled, 'mm/dd/yyyy') As Sampled, T.Description As Type, L.SampledBy From (GeoLog L Left Join Project P On P.TracsNumber = L.TracsNumber) Left Join SAMaterialType T On T.MaterialTypeCode = L.MaterialTypeCode Where P.ADOTPrefix Like '*60*' Order By L.TracsNumber, L.SamplePhase, L.TestHole, L.UpperDepth;

I am using the query in VB.Net to populate a DataTable as follows:

mdtList = New DataTable
Try
da = New OleDb.OleDbDataAdapter(strSql, gstrConnect)
da.Fill(mdtList)

After running this code, mdtList contains zero rows. strSql contains the exact same query as shown above, and I am using the same database.

Does anyone see my problem? I am used to working with SQL Server, and am wondering if this is some quirky thing with Access.

Thanks.
 
Expose the exception in a message box or something, to see if you are getting an exception.
 
I just found the problem.

Even though Access requires * in Like clause, VB.Net still uses % just like SQL Server.

This is an adventure. Many queries written in SQL Server need to be re-written to work in Access. Then, when you use Access syntax in this case, it doesn't work. Fun.

Thanks for the response.
 
if you want to use access with sql-server try using an access project file or adp then you can use sqlserver syntax and storedprocedures just like in sql-server.

Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top