如何 消除 并行错误

blasterboy 2004-07-28 07:31:19
每次我adapter.update(datatable),就会给我报出并发错误:update 0 条记录。

我现在如何才能解决这个问题。

给一个行之有效的解决办法。我现在只能用update来解决这个问题。

还有就是能不能让它不报错误,直接给我update就可以,不用检查什么并行不并行的。

解决了,定有重谢!!!!
...全文
118 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
blasterboy 2004-08-02
  • 打赏
  • 举报
回复
我是自己写的代码阿,不使用自动生成的

还有,我看了他自动生成的代码,勾和不勾上那个选项,生成的代码是一样的!!

.net到底生成了什么东西????
Brunhild 2004-08-02
  • 打赏
  • 举报
回复
在配置adapter中走到“生成SQL语句”时CLICK“高级选项”,将“使用开放式并发”去掉。
blasterboy 2004-08-02
  • 打赏
  • 举报
回复
怎么消除这个并发错误
如果能让他不管三七二十一直接就给我更新就可以
chNET 2004-07-29
  • 打赏
  • 举报
回复

没有vb的,这是别人写一个c#版:

System.Data.SqlClient.SqlConnection mCn
=new System.Data.SqlClient.SqlConnection("...");
System.Data.SqlClient.SqlDataAdapter mDa
=new System.Data.SqlClient.SqlDataAdapter("...",mCn);
System.Data.SqlClient.SqlTransaction mTr
=mCn.BeginTransaction();
try
{

//...............
mDa.UpdateCommand.Transaction= mTr;
mDa.Update(...);
mTr.Commit();
}
catch
{
mTr.Rollback();
}
supergirlly 2004-07-29
  • 打赏
  • 举报
回复
Adapter has get no change.
supergirlly 2004-07-29
  • 打赏
  • 举报
回复
Adapter has get no change.
supergirlly 2004-07-29
  • 打赏
  • 举报
回复
Adapter has get no change.
blasterboy 2004-07-29
  • 打赏
  • 举报
回复
如何给一个adapter.update增加一个事务处理?
blasterboy 2004-07-28
  • 打赏
  • 举报
回复
Private Function getValue(ByRef table As DataTable) As OleDbCommandBuilder
Dim cb As OleDbCommandBuilder
If Not ht.ContainsKey(table) Then
cb = New OleDbCommandBuilder(adapter)
ht.Add(table, cb)
Return cb
Else
Return ht.Item(table)
End If

End Function



ht 是一个hashtable,要来保存oleDBcommandBuilder用的
blasterboy 2004-07-28
  • 打赏
  • 举报
回复
不好意思,是并发错误:)

Select

Public Sub FG_TrueDBSelect(ByVal strSQL As String, ByRef table As DataTable)
FG_MDBClose()
FG_MDBOpen()
Try
conn.Open()
adapter = New OleDbDataAdapter
oCommandBuilder = getValue(table)
adapter.SelectCommand = New OleDbCommand(strSQL, conn)
table.Clear()
adapter.FillSchema(table, SchemaType.Source)
adapter.Fill(table)
oCommandBuilder.RefreshSchema()
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
End Try
End Sub


update



Public Sub FG_TrueDBUpdate(ByRef table As DataTable)

Try
conn.Open()
'If the DataTable is changed nothing
If IsNothing(table.GetChanges) Then
Return
End If
oCommandBuilder = ht.Item(table)
'adapter.DeleteCommand = oCommandBuilder.GetDeleteCommand
'adapter.InsertCommand = oCommandBuilder.GetInsertCommand
adapter.UpdateCommand = oCommandBuilder.GetUpdateCommand
adapter.UpdateCommand.CommandText = makeUpSql(oCommandBuilder.GetUpdateCommand.CommandText)
adapter.Update(table)
FG_MDBClose()
FG_MDBOpen()
Catch ex As Exception
MsgBox(ex.Message)
Finally
table.AcceptChanges()
conn.Close()
End Try
End Sub
chNET 2004-07-28
  • 打赏
  • 举报
回复

并行错误 ? = 并发错误

楼主把你的代码贴出来看看,并发错误的原因有很多...
另,你是更新单表还是多表?

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧