NeonBurner
Feb 3rd, 2004, 11:34 AM
i've done some searching and i know my SQL is right, but i'm getting strange results, has something changed with the LIKE keyword when using OLE? heres what i got
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LB.Items.Clear()
Dim strConn As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="
strConn += Request.PhysicalApplicationPath & "CalTime.mdb"
Dim strSQL As String = "Select * from CalTime where( '7am' Like " & "'" & "%" & txtCriteria.Text & "%" & "'" & ");"
Dim conn As New OleDbConnection(strConn)
Dim Cmd As New OleDbCommand(strSQL, conn)
Dim objDR As OleDbDataReader
If DDEmp.SelectedItem.Text <> " - All - " Then
strSQL += " and empName = '" & DDEmp.SelectedItem.Text & "'"
End If
' msgErr.Text = strSQL
Dim sName As String
Try
conn.Open()
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Do While objDR.Read()
sName = objDR("empName") & " , " & objDR("calDate") & ""
LB.Items.Add(New ListItem(sName))
Loop
conn.Close()
Catch ex As OleDb.OleDbException
msgErr.Text += (ex.Message)
End Try
End Sub
i dont catch any exceptions, if i have txtCriteria blank then i get the right results, when i add an A i should get 3 results but i get none, i added a intCounter in there to see if i was getting the results but not loading them right into ListBox, but its just not grabbing anything, any ideas?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LB.Items.Clear()
Dim strConn As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="
strConn += Request.PhysicalApplicationPath & "CalTime.mdb"
Dim strSQL As String = "Select * from CalTime where( '7am' Like " & "'" & "%" & txtCriteria.Text & "%" & "'" & ");"
Dim conn As New OleDbConnection(strConn)
Dim Cmd As New OleDbCommand(strSQL, conn)
Dim objDR As OleDbDataReader
If DDEmp.SelectedItem.Text <> " - All - " Then
strSQL += " and empName = '" & DDEmp.SelectedItem.Text & "'"
End If
' msgErr.Text = strSQL
Dim sName As String
Try
conn.Open()
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Do While objDR.Read()
sName = objDR("empName") & " , " & objDR("calDate") & ""
LB.Items.Add(New ListItem(sName))
Loop
conn.Close()
Catch ex As OleDb.OleDbException
msgErr.Text += (ex.Message)
End Try
End Sub
i dont catch any exceptions, if i have txtCriteria blank then i get the right results, when i add an A i should get 3 results but i get none, i added a intCounter in there to see if i was getting the results but not loading them right into ListBox, but its just not grabbing anything, any ideas?