Click here to Skip to main content
15,897,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi experts.
i have a database with one table named books so i want to make a search box for a column and show . so after watching this video http://msdn.microsoft.com/en-us/vstudio/bb643828.aspx
i did every part accurately but problem is :
when i made following query :
SQL
SELECT         Bookname, quantity, publisher, author,
FROM            books
WHERE        (Bookname LIKE '@bookname' + '%')

a toolbar control appears in my form but has no textbox so i made it manually

and editing my search_BTN click code to this :
VB
Try
            Me.BooksTableAdapter.BooknameQuery(Me.Book_listDataSet.books, ToolStripTextBox1.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
here i get error that say :Too many arguments to 'Public Overridable Overloads Function BooknameQuery(dataTable As Book_listDataSet.booksDataTable) As Integer
please help me i am a beginner.
Posted
Updated 27-May-13 2:14am
v2

I guess the @bookname is a variable in which you pass the name of the book to be searched.
But you have used it like a string. So, try changing it like below.
SQL
SELECT Bookname, quantity, publisher, author,
FROM books
WHERE (Bookname LIKE @bookname + '%')
 
Share this answer
 
Comments
Dr_miti 26-May-13 5:01am    
thanx for reply but not works
when i simply make query like this :
SELECT Bookname, quantity, publisher, author,
FROM books
WHERE (Bookname = ?)
it works but just accepts exact string and i dont know how to add ( like '%' ) to my query.
Can you post the code of that function where you are querying to Database ?
Dr_miti 26-May-13 7:07am    
my search_BTN click code is :

Try
Me.BooksTableAdapter.BooknameQuery(Me.Book_listDataSet.books, ToolStripTextBox1.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
this code takes user searched string and fill datagrid control in my winform.
And where is that select query ?

You have referred a video before doing this. I guess I have to see that.
Then I will reply to you after I watch that video.
Hi all...
thanx for yuor help . my prblem solved by doing this :

1- Query
SQL
SELECT Bookname, quantity, publisher, author,
FROM books
WHERE (Bookname LIKE @param1)

2- search BTN code :

Try
dim Myparam as string = "%" & ToolStripTextBox1.Text & "%"
Me.BooksTableAdapter.BooknameQuery(Me.Book_listDataSet.books, Myparam)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
 
Share this answer
 
Hi...
see this,its may helpful to u.
use ur cmd like this.

cmd = new mysqlcommand("select Bookname, quantity, publisher, author,
FROM books where bookname Like +@name+'%'",con);

thank u.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900