使用文本框的搜索方法 [英] Search method using textbox
问题描述
大家好
我正在使用文本框和按钮创建简单搜索页面
当我尝试搜索时,结果仅在我在文本框中键入数字时显示
这是我的Sql
Hi All
I'm Creating Simple Search Page Using Textbox and Button
When I try Searching , The results Show only when I type Numbers in textbox
This is my Sql
Select Name from Users Where Name Like '%{0}%'
注意:{0}是方法中的字段编号(类)
我在后面的代码中调用它的函数并传递textbox.text
不是问题
方法正常工作
但问题是:
我有以下表中的用户:
Maria 56 - Barak - Rano30
但是当我尝试输入文本框Maria - >结果什么都没有
当我尝试输入Maria 56 - >结果什么都没有
但是当我输入文本框56时,结果显示在gridview中
任何人都可以帮助我???
我尝试了什么:
我尝试在选择SQL中进行更改但没有改变
Note : {0} is the Field Number in Method (Class)
I call it's Function in code behind and pass textbox.text
it is not the problem
The method Working Correctly
But the problem :
I have The following users in table :
Maria 56 - Barak - Rano30
But When I try To type in textbox Maria --> the result is nothing
When I try to type Maria 56 --> the result is nothing
But when I type in textbox 56 the result show in gridview
anyone can help me ???
What I have tried:
I tried changing in Select SQL But nothing changed
推荐答案
您还没有给我们提供必须查看的代码,所以我只能用{0}字段编号来结束它的SQL语句。
我们无法看到这个类是什么或者它做了什么,但你应该检查返回的SQL语句,看它是否是一个有效的sql语句,然后再对数据库运行它。除非您在名称字段中搜索{0},否则上述声明不会发生。
也许您所追求的是
You haven't given us must code to look at so I can only conclude its your SQL statement with the {0} field number.
We cant see what this class is or what it does, but you should check the returned SQL statement to see if its a valid sql statement before running it against the database. The statement above is not unless you are searching for {0} in the name field.
Maybe what you are after is
Select Name from Users Where Name like '%[0-9]%' and name like '%' + textbox.text + '%'
这篇关于使用文本框的搜索方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!