搜索数据库问题 [英] Search in database problem

查看:62
本文介绍了搜索数据库问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家。

我有一个数据库,其中一个表名为books,所以我想为列和节目创建一个搜索框。观看此视频后 http://msdn.microsoft.com/en-us/vstudio/bb643828.aspx

i准确地完成了每个部分,但问题是:

当我做出以下查询时:

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 :

SELECT         Bookname, quantity, publisher, author,
FROM            books
WHERE        (Bookname LIKE '@bookname' + '%')



a工具栏控件出现在我的表单中,但没有文本框,所以我手工制作



并编辑我的search_BTN点击代码: br />


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 :

Try
            Me.BooksTableAdapter.BooknameQuery(Me.Book_listDataSet.books, ToolStripTextBox1.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try

这里我得到的错误是:''Public Overridable Overloads函数BooknameQuery(dataTable as Book_listDataSet.booksDataTable)的参数太多

请帮帮我,我是初学者。

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.

推荐答案

我想 @bookname 是一个变量,您可以在其中传递要搜索的书籍的名称。

但是你已经像字符串一样使用它了。所以,尝试改变它如下。

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.
SELECT Bookname, quantity, publisher, author,
FROM books
WHERE (Bookname LIKE @bookname + '%')


大家好...

thanx for yuor help。我的问题解决了这个问题:



1-查询

Hi all...
thanx for yuor help . my prblem solved by doing this :

1- Query
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


嗨......

看到这个,它可能对你有帮助。

像这样使用你的cmd。



cmd = new mysqlcommand(选择书名,数量,出版商,作者,

来自bookname的书籍,如+ @ name +''%'',con);



谢谢你。
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.


这篇关于搜索数据库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆