SQL Querry with user defined search

  • Thread starter Thread starter Jim Campau
  • Start date Start date
J

Jim Campau

I need help as I am new to VB.NET, could someone please show me a code
example that will do the following or what is wrong with mine:

I have 1 Comand Button (btnsearch) and 1 text box (txtsearch).

I have an access database (Documents) that I want to search for records. I
have a data adapter (OleDbDataAdapter2) that fills a grid (DsDocuments1)
based on the (txtsearch) text box that a user will fill. OleDbDataAdapter1
returns all rows and is working.


This is the part I am doing wrong somehow:
OleDbDataAdapter2 Querry:
SELECT ID, Doc_Title, Doc_Date, Doc_Keywords, Misc_Info, Doc_Location FROM
Documents WHERE (Doc_Title LIKE [txtSearch])

Command Button (btnsearch):
DsDocuments1.Clear()
OleDbConnection1.Open()
OleDbDataAdapter2.Fill(DsDocuments1)
OleDbConnection1.Close()

Thanks in Advance
 
Jim Campau said:
I need help as I am new to VB.NET, could someone please show me a code
example that will do the following or what is wrong with mine:

I have 1 Comand Button (btnsearch) and 1 text box (txtsearch).

I have an access database (Documents) that I want to search for records. I
have a data adapter (OleDbDataAdapter2) that fills a grid (DsDocuments1)
based on the (txtsearch) text box that a user will fill. OleDbDataAdapter1
returns all rows and is working.


This is the part I am doing wrong somehow:
OleDbDataAdapter2 Querry:
SELECT ID, Doc_Title, Doc_Date, Doc_Keywords, Misc_Info, Doc_Location FROM
Documents WHERE (Doc_Title LIKE [txtSearch])

Command Button (btnsearch):
DsDocuments1.Clear()
OleDbConnection1.Open()
OleDbDataAdapter2.Fill(DsDocuments1)
OleDbConnection1.Close()

You should use a parameter in your query string and set the value of
the parameter to the value in the text box just before you call Fill.

See OleDbCommand.Parameters for more information.
 
Back
Top