SQL in vb.net

tourvi

New member
Joined
May 5, 2006
Messages
2
Programming Experience
1-3
I am trying to create a query using VB.NET, 2003.
I have put the query in Access, and it works fine, but when I put it in VB, i get null. I am searching for the word 'sam' in a field called 'problem description'. The only problem is that there are more words in the field than just 'sam', so I cant use the equals operator. Please help.

Here is the query in Access:
SELECT [ticketNumber]
FROM Ticket
WHERE problemDescription LIKE '*sam*';


Here is the code from VB:
Dim sql As String = "SELECT ticketNumber FROM Ticket " & _
"WHERE problemDescription LIKE '*sam*'"
adpList = New OleDbDataAdapter(sql, cnnList)

adpList.Fill(dsList, "custTable")
DataGrid1.DataSource = dsList.Tables("custTable").DefaultView

the connection is fine, and other queries work.
I don't know if VB and Access use different SQL versions or different query languages. I think the problem lies in the '*sam*' section. Maybe VB has a different keyword instead of LIKE to use when searching a field in the database.

PS. i posted this is general discussion forum, but thought this forum was more fitting.
 
And try not to double post.... between the two threads it's now been answred more than once.

-tg
 
Back
Top