Results 1 to 8 of 8

Thread: Like statement not working [resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    US
    Posts
    68

    Like statement not working [resolved]

    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

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         LB.Items.Clear()
    3.         Dim strConn As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="
    4.         strConn += Request.PhysicalApplicationPath & "CalTime.mdb"
    5.         Dim strSQL As String = "Select * from CalTime where( '7am' Like " & "'" & "%" & txtCriteria.Text & "%" & "'" & ");"
    6.         Dim conn As New OleDbConnection(strConn)
    7.         Dim Cmd As New OleDbCommand(strSQL, conn)
    8.         Dim objDR As OleDbDataReader
    9.  
    10.         If DDEmp.SelectedItem.Text <> " - All - " Then
    11.             strSQL += " and empName = '" & DDEmp.SelectedItem.Text & "'"
    12.         End If
    13.        ' msgErr.Text = strSQL
    14.  
    15.         Dim sName As String
    16.         Try
    17.             conn.Open()
    18.             objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    19.             Do While objDR.Read()
    20.                 sName = objDR("empName") & " ,  " & objDR("calDate") & ""
    21.                 LB.Items.Add(New ListItem(sName))
    22.             Loop
    23.             conn.Close()
    24.         Catch ex As OleDb.OleDbException
    25.             msgErr.Text += (ex.Message)
    26.         End Try
    27.  
    28.     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?
    Last edited by NeonBurner; Feb 3rd, 2004 at 12:59 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width