sql连接到vb.net的事务问题 [英] Transaction problem with sql connection to vb.net

查看:77
本文介绍了sql连接到vb.net的事务问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我一直在努力与SQL Server事务的原子性.如果我们想让所有插入命令完成或全部放弃,我们通常使用BeginTrans,committrans,rollbacktrans.

但是,当我想在表中插入一行并且同样必须更新到该表(另一行)时,它却失败了.

有人有任何解决方法吗?

致以最诚挚的问候

Jaidev Khatri

Hi,

I have been struggling with sql server transaction atomicity. If we like to give all insert command to be done or all abandoned, we normally use BeginTrans, committrans, rollbacktrans.

But it is getting failed when I like to insert a row in a table and similarly I have to update into that table (an another row).

Do someone have any workaround.

Thanks & Best Regards

Jaidev Khatri

推荐答案

这只是简单的事情


如果Erowcheck = 0,那么
StartTrans("promotion")
streamid = Val(clscmn.GetScalarvalue(从session_student_class中选择stream_id,其中reg_id ="&Regid&和session_id ="&Pre_Session))
str =插入session_student_class(reg_id,class_id,session_id,sec_id,pro_status,ses_cls_id,stream_id)值("&Regid&,"&NextCls&,"&Cur_Session&,"&SecID&,2," &NSesNClsId&,"&streamid&)"
clscmn.inserts(str)

str ="update session_student_class set promst = 1,其中reg_id ="&Regid&和ses_cls_id ="&SesClsID
cmnmod.Updates(str)
CommitTrans("promotion")

我只有一个连接来更新/插入,并且只有一个命令来管理它.选择查询有差异.连接.

问题是整个表都处于锁定状态.如果将在行级别.思想可以有所作为.

请为您解决.

杰伊·哈特里(Jay Khatri)
Its just a simple thing


If Erowcheck = 0 Then
StartTrans("promotion")
streamid = Val(clscmn.GetScalarvalue("select stream_id from session_student_class where reg_id=" & Regid & " and session_id=" & Pre_Session))
str = "insert into session_student_class (reg_id,class_id,session_id,sec_id,pro_status,ses_cls_id,stream_id) values (" & Regid & "," & NextCls & "," & Cur_Session & "," & SecID & ",2," & NSesNClsId & "," & streamid & ")"
clscmn.inserts(str)

str = "update session_student_class set promst=1 where reg_id=" & Regid & " and ses_cls_id=" & SesClsID
cmnmod.Updates(str)
CommitTrans("promotion")

I just have one connection to update/ insert and just have one command to manage it like this. Select queries have diff. connection.

The problem is the entire table locking. If it will be at row level. The thinks can make a difference.

Your solution please.

Jay Khatri


这篇关于sql连接到vb.net的事务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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