Hello, i'm trying to make a searchfilter where i can search records on the date i give in the textbox. What is the best way to do this? I've tried somethings but nothing works very well.
I've found this script and i tried to modify it to search at the ID but then I'll get a error:
I know it has something to do with the string declaration of the sql(I think).
How can i make it work and can somebody please tell me how i can make the searchfilter best for searching a date?
VB.NET:
Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdSearch.Click
lblError.Text = ""
Dim strSQL As String
strSQL = "SELECT adress, phoneNumber FROM mydatabase WHERE name='" & txtName.Text & "'"
Dim cmd As OleDbCommand = New OleDbCommand(strSQL, cnn)
Try
cnn.Open()
'build the dataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader
'read the first row
If reader.Read() Then
'set the textBoxs with appropriate data
Me.txtAddress.Text = reader.GetValue(0)
Me.txtPhoneNo.Text = reader.GetValue(1)
Else
Me.txtAddress.ResetText()
Me.txtPhoneNo.ResetText()
lblError.Text = "No Data Found"
End If
reader.Close()
Finally
Try
cnn.Close()
Catch : End Try
End Try
End Sub
End Class
I've found this script and i tried to modify it to search at the ID but then I'll get a error:
VB.NET:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
I know it has something to do with the string declaration of the sql(I think).
How can i make it work and can somebody please tell me how i can make the searchfilter best for searching a date?