Is there a reason why one sql statement works and not the other?
Public Sub ReadMyData(ByVal myString As String)
'This first statement is returned from the cbo_click and works fine
'SELECT * FROM tblA_Files ORDER BY File;
'This statement is returned by the bthSearch_Click and does not work
'SELECT * FROM tblA_Files WHERE Title LIKE "*lake*" AND Title LIKE "*water*" ORDER BY FILE;
'Both statements work fine in Access sql view
If TestDBConn() Then
Dim myCommand As New OleDbCommand(myString, cngisfmDB)
drgisfmDB = myCommand.ExecuteReader()
While drgisfmDB.Read()
.
.
'populate Listview
End While
End If
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
If TestDBConn() Then
.
.
ListView1.Items.Clear()
For i = 0 To cboDocumentGroup.Items.Count - 1
txtGroup = cboDocumentGroup.Items(i).ToString
If txtGroup <> "All" Then
If rdoAnd.Checked = True Then
If txtS1.Length > 0 And _
txtS2.Length > 0 Then
strcngisfmdb = "SELECT * FROM tbl" + cboDocumentGroup.Items(i).ToString + _
" WHERE Title LIKE ""*" + txtS1 + "*"" AND Title LIKE ""*" + txtS2 + "*"" ORDER BY FILE;"
ReadMyData(strcngisfmdb)
drgisfmDB.Close()
End If
End If
End If
Next i
End If
Me.Text = ListView1.Items.Count.ToString
End If
bolSearch = False
txtGroup = ""
ListView1.Select()
cngisfmDB.Close()
End Sub
Private Sub cboDocumentGroup_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDocumentGroup.SelectedIndexChanged
If cboDocumentGroup.Text = "All" Then
.
.
Else
ListView1.Items.Clear()
strcngisfmdb = "SELECT * FROM tbl" + cboDocumentGroup.Text + " ORDER BY File;"
ReadMyData(strcngisfmdb)
ListView1.Select()
drgisfmDB.Close()
cngisfmDB.Close()
End If
End Sub
Public Sub ReadMyData(ByVal myString As String)
'This first statement is returned from the cbo_click and works fine
'SELECT * FROM tblA_Files ORDER BY File;
'This statement is returned by the bthSearch_Click and does not work
'SELECT * FROM tblA_Files WHERE Title LIKE "*lake*" AND Title LIKE "*water*" ORDER BY FILE;
'Both statements work fine in Access sql view
If TestDBConn() Then
Dim myCommand As New OleDbCommand(myString, cngisfmDB)
drgisfmDB = myCommand.ExecuteReader()
While drgisfmDB.Read()
.
.
'populate Listview
End While
End If
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
If TestDBConn() Then
.
.
ListView1.Items.Clear()
For i = 0 To cboDocumentGroup.Items.Count - 1
txtGroup = cboDocumentGroup.Items(i).ToString
If txtGroup <> "All" Then
If rdoAnd.Checked = True Then
If txtS1.Length > 0 And _
txtS2.Length > 0 Then
strcngisfmdb = "SELECT * FROM tbl" + cboDocumentGroup.Items(i).ToString + _
" WHERE Title LIKE ""*" + txtS1 + "*"" AND Title LIKE ""*" + txtS2 + "*"" ORDER BY FILE;"
ReadMyData(strcngisfmdb)
drgisfmDB.Close()
End If
End If
End If
Next i
End If
Me.Text = ListView1.Items.Count.ToString
End If
bolSearch = False
txtGroup = ""
ListView1.Select()
cngisfmDB.Close()
End Sub
Private Sub cboDocumentGroup_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDocumentGroup.SelectedIndexChanged
If cboDocumentGroup.Text = "All" Then
.
.
Else
ListView1.Items.Clear()
strcngisfmdb = "SELECT * FROM tbl" + cboDocumentGroup.Text + " ORDER BY File;"
ReadMyData(strcngisfmdb)
ListView1.Select()
drgisfmDB.Close()
cngisfmDB.Close()
End If
End Sub