启用乐观并发 [英] Enable optimistic concurrency

查看:61
本文介绍了启用乐观并发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在2010年中有一个vb.net.我在项目中插入了本地sqlce数据库3.5.当我进入可视数据设计器并将表拖到该表上,然后右键单击tableadapter并单击高级按钮时,开放式并发"选项被禁用.意思是,我无法选择它.如何启用它.当我去更新该表时,这会导致并发错误,因此不会更新该行.有任何建议吗?

I have a vb.net in vs 2010. I have a local sqlce database 3.5 that I inserted in the project. When I go into the visual data designer and drag a table to it then right click on the tableadapter, and hit the advanced button, the "optimistic concurrency" option is disabled. Meaning, I cant select it. How can I enable it. When I go to update this table it is causing a concurrency error, thus not updating the row. any suggestions?

推荐答案

有些东西没有加起来.您是在说您在多用户环境中使用SQLCE吗?如果没有,那么您就不会遇到并发问题.听起来您的代码似乎在争夺记录控制权.没有看到您的代码如何检索和更新记录,很难告诉您发生了什么.
Something isn''t adding up. Are you saying that you''re using SQLCE in a multiuser environment?? If not, then you shouldn''t be having concurrency problems. It sounds as though your code is competing against itself for control of records. Without seeing how you code is retrieving and updating records, it''s pretty difficult to tell you what''s going on.


David,

这是代码:

''尝试
如果tempDate =今天和bsRunInformation.Current("UniqueNumber")= Fields(1)然后
frmMain.bsRunInformation.Current(描述")= StripString(Fields(2))
frmMain.Validate()
frmMain.bsRunInformation.EndEdit()
frmMain.TblRunInformationTableAdapter.Update(frmMain.DsSkySkor1.tblRunInformation)''很快我就得到了DBConcurrencyException未处理

''将Ex捕获为DBConcurrencyException

''尝试结束
MsgBox(更新当前记录"和字段(2))
其他

frmMain.TblRunInformationTableAdapter.FillSingleRow(frmMain.DsSkySkor1.tblRunInformation,Today,Fields(1))
frmMain.bsRunInformation.Current(描述")= StripString(Fields(2))
frmMain.Validate()
frmMain.bsRunInformation.EndEdit()
frmMain.TblRunInformationTableAdapter.Update(frmMain.DsSkySkor1.tblRunInformation)''我称其为``我很快得到了DBConcurrencyException未处理 ''将Ex捕获为DBConcurrencyException

''尝试结束
如果结束
Hi David,

Here is code:

''try
If tempDate = Today And bsRunInformation.Current("UniqueNumber") = Fields(1) Then
frmMain.bsRunInformation.Current("Description") = StripString(Fields(2))
frmMain.Validate()
frmMain.bsRunInformation.EndEdit()
frmMain.TblRunInformationTableAdapter.Update(frmMain.DsSkySkor1.tblRunInformation) ''Soon as I call this I get DBConcurrencyException not handled

''Catch ex As DBConcurrencyException

''End Try
MsgBox("Update current record " & Fields(2))
Else

frmMain.TblRunInformationTableAdapter.FillSingleRow(frmMain.DsSkySkor1.tblRunInformation, Today, Fields(1))
frmMain.bsRunInformation.Current("Description") = StripString(Fields(2))
frmMain.Validate()
frmMain.bsRunInformation.EndEdit()
frmMain.TblRunInformationTableAdapter.Update(frmMain.DsSkySkor1.tblRunInformation)''Soon as I call this I get DBConcurrencyException not handled
''Catch ex As DBConcurrencyException

''End Try
End If


这篇关于启用乐观并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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