Hey,
I have an app that pulls data from an access database, everything is working fine, except i'm trying to set up a simple search function, where the user would enter a model number in cbModel and push a go button and have the data be displayed. I'm new to this. I don't know if the syntax is wrong for my select statement or what. It seems to try and then never bring back any results, even if is an exact result in the database. Here's the code.
Dim adapter AsNew OleDb.OleDbDataAdapter
Dim connection AsNew OleDb.OleDbConnection
Dim searchresults AsNew DataSet
Dim searchtime AsString
connection.ConnectionString = "provider=microsoft.jet.oledb.4.0;Data source=q:\data\isim.mdb"
connection.Open()
searchtime = "SELECT * FROM isimtable WHERE model = '*cbModel.text*'"
adapter = New OleDb.OleDbDataAdapter(searchtime, connection)
adapter.Fill(searchresults, "Search")
Try
cbModel.Text = searchresults.Tables("search").Rows(inc).Item(1)
tbSerial.Text = searchresults.Tables("search").Rows(inc).Item(2)
tbAsset.Text = searchresults.Tables("search").Rows(inc).Item(3)
rtbHistory.Text = searchresults.Tables("search").Rows(inc).Item(4)
rtbNotes.Text = searchresults.Tables("search").Rows(inc).Item(5)
tbUser.Text = searchresults.Tables("search").Rows(inc).Item(6)
cbLocation.Text = searchresults.Tables("search").Rows(inc).Item(7)
cbSchedule.Text = searchresults.Tables("search").Rows(inc).Item(8)
dtpDateSent.Text = searchresults.Tables("search").Rows(inc).Item(9)
dtpDateRec.Text = searchresults.Tables("search").Rows(inc).Item(10)
tbPrevUser.Text = searchresults.Tables("search").Rows(inc).Item(11)
Catch ex As Exception
MsgBox("There are no results")
btnGo.Visible = False
inc = 0
navigaterecords()
I have an app that pulls data from an access database, everything is working fine, except i'm trying to set up a simple search function, where the user would enter a model number in cbModel and push a go button and have the data be displayed. I'm new to this. I don't know if the syntax is wrong for my select statement or what. It seems to try and then never bring back any results, even if is an exact result in the database. Here's the code.
Dim adapter AsNew OleDb.OleDbDataAdapter
Dim connection AsNew OleDb.OleDbConnection
Dim searchresults AsNew DataSet
Dim searchtime AsString
connection.ConnectionString = "provider=microsoft.jet.oledb.4.0;Data source=q:\data\isim.mdb"
connection.Open()
searchtime = "SELECT * FROM isimtable WHERE model = '*cbModel.text*'"
adapter = New OleDb.OleDbDataAdapter(searchtime, connection)
adapter.Fill(searchresults, "Search")
Try
cbModel.Text = searchresults.Tables("search").Rows(inc).Item(1)
tbSerial.Text = searchresults.Tables("search").Rows(inc).Item(2)
tbAsset.Text = searchresults.Tables("search").Rows(inc).Item(3)
rtbHistory.Text = searchresults.Tables("search").Rows(inc).Item(4)
rtbNotes.Text = searchresults.Tables("search").Rows(inc).Item(5)
tbUser.Text = searchresults.Tables("search").Rows(inc).Item(6)
cbLocation.Text = searchresults.Tables("search").Rows(inc).Item(7)
cbSchedule.Text = searchresults.Tables("search").Rows(inc).Item(8)
dtpDateSent.Text = searchresults.Tables("search").Rows(inc).Item(9)
dtpDateRec.Text = searchresults.Tables("search").Rows(inc).Item(10)
tbPrevUser.Text = searchresults.Tables("search").Rows(inc).Item(11)
Catch ex As Exception
MsgBox("There are no results")
btnGo.Visible = False
inc = 0
navigaterecords()