一个连接上有多个查询... [英] Multiple quries on one connection...
本文介绍了一个连接上有多个查询...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对C#中的一个按钮事件执行插入和更新sql查询...
我想要这个...以便我将在datable的表上进行更新,并在另一个表中插入一些数据.同时...
谁能给我一些想法..
i want to excute insert and update sql quries on one button event in C#...
i want to to this... so that i will update on table in datable and insertsome data in another table. at the same time...
can anyone give me some idea about this..
推荐答案
对插入和更新查询都使用一个过程.
检查TestProc
Use a procedure with both insert and update queries.
Check the TestProc
CREATE PROCEDURE TestProc
@Column1 varchar(50),
@Column2 varchar(50),
@Column3 varchar(50),
@Column4 varchar(50)
AS
BEGIN
insert into Table1(Column1, Column2) values (@Column1, @Column2)
update Table2 set Column4 = @Column4 where column3=@column3
END
我相信以上答案已经足够了.但是,正如您所知道的,您可以使用事务执行多个插入/更新/删除,并在所有更改失败时回滚所有更改.
只需查看此链接 [
Hi,
I believe the above answers are good enough. But just so that you know, you can use transactions to execute multiple inserts/updates/deletes and rollback all changes if any of them fails.
Just take a look at this Link[^]
Hope this helps, Regards.
^ ]可能会对您有所帮助.
this[^] might help you.
这篇关于一个连接上有多个查询...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文