如何将文本框值与数据库字段进行比较 [英] How to compare textbox value to the database field

查看:157
本文介绍了如何将文本框值与数据库字段进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是asp.net的新手,我对asp.net存有疑问.如何将文本框值与数据库字段进行比较,以及如何在gridview中检索匹配的行.

hi am new to asp.net , I have one doubt in asp.net. How to compare the textbox value with the database field and to retrieve the matched rows in gridview . please any one give an idea.

推荐答案



编写一个存储过程或查询以接受一些文本(在您的情况下为文本框文本),然后使用查询来提取数据,如下所示:

Hi,

Write a stored procedure or query which accepts some text(in your case it is textbox text) and pull the data using query like following

select (your fileds) from yourtable where (yourdatabase field to be compared) like ''%''+your textbox value+''%''



希望这对您有帮助



Hope this helps


编写一个sp并使用sql命令对象在一个参数中发送文本框值.
查询将是
Write a sp and send text box value in one parameter using sql command object.
Query will be
select * from TableName where TableField = @TextBoxValue



现在,使用run cmd.ExecuteNonQuery()并使用dataadapter将数据填充到数据集中.并将此数据集绑定到gridview.



Now, using run cmd.ExecuteNonQuery() and using dataadapter fill data to dataset. and bind this dataset to gridview.


尝试执行此存储过程,以比较txtbox中的txt和DB中的值.
首先给存储过程赋值,它将与db值完全相同


@supname char(7)
作为
开始
选择
supid_name为[供应商名称]
来自供应商
其中
(supid_name = @ supname)
结束
Try This Store procedure for comparing txt from txtbox and value from DB.
first give the value to storeprocedure it will compaire from db value


@supname char(7)
As
Begin
Select
supid_name as [Supplier Name]
From Supplier
where
(supid_name=@supname)
End


这篇关于如何将文本框值与数据库字段进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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