I'm trying to know what is the correct syntax of sql wildcard expression in vb.net
what I want is to select my record when my dayVariable match the Day record, sample if my dayVariable = "T" then my sql expression need to display all record in Day that has a letter of "T" even "TF" or "FT", as long as there is a "T"
All I try only display record which Day has a record match exactly to "T"
SELECT * FROM tblSomething WHERE Day LIKE '%" + dayVariable + "%'
SELECT * FROM tblSomething WHERE Day LIKE '%" & dayVariable & "%'
Note: I try to build query in sql express like this:
SELECT * FROM tblSomething WHERE Day LIKE '%T%'
and I achieve to display all records that has "T" letter in Day column.
This is my real Vb.net
Private Function checkSecConflict(ByVal sTime As String, ByVal eTime As String, ByVal secID As String, ByVal day As String) As Boolean
If Connect.State = ConnectionState.Closed Then
Connect.Open()
End If
Dim cmd2 As New SqlCommand("Select * from tblSubjectOffer Where eTime > " & sTime & " AND sTime < " & eTime & " AND Day LIKE '%' + day + '%' AND SectionID = '" & secID & "'", Connect)
Dim dr As SqlDataReader = cmd2.ExecuteReader()
dr.Read()
If dr.HasRows Then
Return True
Else
Return False
End If
dr.Close()
cmd2.Dispose()
End Function
just ignore my where statement about the time and secID, because I figured out that my wildcard about day is the real problem, I think so, :)
Thanks in advance to those who want to help me solve my problem,