I'm trying to filter a datagrid on the fly using this:
and
However, the LIKE command won't work like it should. Is there anything I can do to make this work?
Code:
On Page Load...
Dim mySort As String
If Session("Sort") = "" Then
mySort = "SELECT * FROM Import"
OleDbDataAdapter1.SelectCommand = New OleDb.OleDbCommand(mySort, OleDbConnection1)
OleDbDataAdapter1.Fill(dsInv)
dgInv.DataBind()
Else
mySort = Session("Sort")
OleDbDataAdapter1.SelectCommand = New OleDb.OleDbCommand(mySort, OleDbConnection1)
OleDbDataAdapter1.Fill(dsInv)
dgInv.DataBind()
End If
Code:
On cmdSearch.Click...
Dim vCrit As String = txtCriteria.Text
If cmbCols.SelectedValue = "Description" Then
If vCrit = "" Then
Session("Sort") = "SELECT * FROM Import ORDER BY Description"
Else
Session("Sort") = "SELECT * FROM Import WHERE Description LIKE '" & vCrit & "' ORDER BY Description"
End If
End If
Session("Crit") = vCrit
Response.Redirect("inventory.aspx")
However, the LIKE command won't work like it should. Is there anything I can do to make this work?