Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

performing search using value from textbox control

Status
Not open for further replies.

knaya

MIS
Dec 4, 2003
51
US
guys,
this question must be so simple casue i cant find the solution anywhere..basically, i have a textbox that after a user enters a keyword and presses the submit button, it display all records matching the keyword.. the problem is i cant get it to work when a word is entered into the textbox.. attached is my code, i wil appreciate any help
:)

Sub Button_Click(ByVal s As Object, ByVal e As EventArgs)
Dim conbooks As OleDbConnection
Dim cmdselect As OleDbCommand


conbooks = new OleDbConnection ( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=E:\accounts\knaya\logs.mdb")
cmdselect = new OleDbCommand ("Select booktitle, author, price From online Where author LIKE (textbox1.text)", conbooks)

conbooks.Open()
dgrdTitles.Datasource = cmdselect.ExecuteReader()
dgrdTitles.DataBind()
conbooks.Close()

dgrdTitles.visible = true
 
In your like statement you need the text to have single quotes around it. You also need to pass the textbox1.text as a value not a field.

LIKE '" & textbox1.text & "'"

Try this!

Hope everyone is having a great day!

Thanks - Jennifer
 
Jennifer,
thanks for replying,
i tried it but it gives me this error:
BC30455: Argument not specified for parameter 'connection' of 'Public Sub New(cmdText As String, connection As System.Data.OleDb.OleDbConnection, transaction As System.Data.OleDb.OleDbTransaction)'.

this is what i used:
cmdselect = new OleDbCommand ("Select booktitle, author, price From online Where author LIKE '"&textbox1.text&"'", conbooks)
any suggestions.. thanks
 
Code:
cmdselect = new OleDbCommand ("Select booktitle, author, price From online Where author LIKE '" & textbox1.text & "', conbooks)

try this...
 
checkai,
you are ze greatest, it worked.. muchos gracious..

Jennifer, thanks also, its ironic you replied cause i saw a topic that was kinda similar that you answered and hoped that you would be online to see my question and help me with it, and you were.. thanks.. :)
 
just needed a little better spacing and 1 less quote...nothing too bad...

glad to help!
 
I am glad to help as well. This forum is great - group efforts. :)

Hope everyone is having a great day!

Thanks - Jennifer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top