Web Development



VB.NET Access DB DataSet problem

By culbysl ·
I'm developing a VB.NET 2005 application with an MS Access backend. The Queries for the most part are "LIKE" queries, and they will not return rows in the application when querying in Access I return rows. When I run a "=" query I return rows from the application and in Access. The query is as follows:

strSQL = "SELECT [ID], [Subject], [Body], [Received], [From] " & _
"FROM " & strTableName & " " & _
"WHERE (((Body) Like """ & strCriteria1 & """ And (Body) Like """ & strCriteria3 & """)) " & _
"ORDER BY Received DESC; "

I would love to hear from anyone that has had this problem and knows a work around. As you can see I am passing in the table name and 2 variables in the where statement. When I hardcode the table name and where criteria I still return nothing. Thanks in advance for you help.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Well it doesn't look right to me

by Tony Hopkinson In reply to VB.NET Access DB DataSet ...

but Access SQL syntax is not a speciality.

Select ... From someTable Where someField Like '%any%'

PS you don't want to make a habit of building strings like this in .NET

Use the format method of string, or if you need more control, the stringbuilder class.

I hesitite to ask, but you have considered SQL injection attacks as well?
if not you might want to look up parameterised queries.


Related Discussions

Related Forums