一键事件中使用C#进行搜索和更新 [英] searching and updating using C# in one button event

查看:87
本文介绍了一键事件中使用C#进行搜索和更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想搜索数据库并单击一个按钮来更新它..
所以我们必须使用多个查询..有人可以帮助我..如何使用多个查询...

I want to search the database and update it on click of one button..
so we have to use multiple quries.. can anyone pls help me .. how to use multiple quries...

推荐答案

更新<某些表名>
设置< col1> =< value1>
其中< col2> =<搜索标准1> AND< col3> =<搜索条件2>

依此类推....
Update <some table name>
Set <col1> = <value1>
where <col2> = <search criteria1> AND <col3> = <search criteria2>

and so on....




不确定我有多远解决您的问题,但是如果您的搜索和更新是相关的并且是单个按钮事件的一部分,那么您宁可去创建存储过程,这也将为您提供使用存储过程的许多优点.

如果您仍然不愿意使用存储过程,则可以在代码中编写这两种方法的后面-一种用于搜索,另一种用于Update.只要您的搜索条件得到满足,就调用Update,否则调用.在搜索和更新"方法中,编写单行参数化查询以与数据库进行交互.

HTH

问候
拉杰夫



如果有帮助,请投票并标记答案为可接受.




Not so sure how far I have got your problem.But if your search and update are related and part of a single button event, then you can rather go for creating a stored procedure.This will also give you the many advantages of using stored procedures.

If you are still reluctant to go for the stored procedures, you can write in your code-behind the two methods - one for Search and the other for Update.Whenever your Search criteria gets satisfied, give a call to Update, else not.And in Search and Update methods, write the one-line parametrized query to interact with the database.

HTH

Regards
Rajeev



Please vote and mark the answer as accepted if this helps you.



这篇关于一键事件中使用C#进行搜索和更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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