Im having some trouble using the SQL Like command with multiple conditions
where as the first line of code works with one condition the second one doesnt even thought it doesnt return any errors
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE chname LIKE '%" & txtFRname.Text & "%'", myConnection)
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '%" & txtFRdob.Text & "%')", myConnection)
Full Code is below
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source =" & Server.MapPath("db2.mdb")
Dim myConnection As OleDbConnection = New OleDbConnection
myConnection.ConnectionString = connString
' create a data adapter
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '%" & txtFRdob.Text & "%')", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet
' fill dataset
da.Fill(ds, "chdetails")
' Attach DataSet to DataGrid
GridView1.DataSource = ds
GridView1.DataBind()
MultiView1.SetActiveView(child)
Where am I going wrong
where as the first line of code works with one condition the second one doesnt even thought it doesnt return any errors
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE chname LIKE '%" & txtFRname.Text & "%'", myConnection)
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '%" & txtFRdob.Text & "%')", myConnection)
Full Code is below
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source =" & Server.MapPath("db2.mdb")
Dim myConnection As OleDbConnection = New OleDbConnection
myConnection.ConnectionString = connString
' create a data adapter
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '%" & txtFRdob.Text & "%')", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet
' fill dataset
da.Fill(ds, "chdetails")
' Attach DataSet to DataGrid
GridView1.DataSource = ds
GridView1.DataBind()
MultiView1.SetActiveView(child)
Where am I going wrong