主题:关于dataset的保存不可靠和并发性的问题
Dim AddID_str As String = "select * from LS where SjID='AddID' "
Dim AddID_Ra As New OleDbDataAdapter(AddID_str, CnnStr)
Dim AddID_Set As New DataSet
Dim Add_Tb As New DataTable("AddId_Tb")
Dim Cbdr As New OleDbCommandBuilder(AddID_Ra) '自动生成SQL更新DATASET到数据源
AddID_Ra.Fill(Add_Tb)
AddID_Set.Tables.Add(Add_Tb)
Dim Add As Integer, I As Integer, ZJ As Integer, Zj1 As String
Add = AddID_Set.Tables("AddId_Tb").Rows.Count
I = Add - 1
Bm = AddID_Set.Tables("AddId_Tb").Rows(I)("SjZ") '读取编号
ZJ = Int(MyDES.DesJieM(Bm, Ma)) '编号解密
ZJ = ZJ + 1 '编号+1'
Zj1 = MyDES.DesJiaM(ZJ.ToString, Ma) '编号加密'
AddID_Set.Tables("AddID_Tb").Rows.Add() '添加一行'
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjID") = "AddID" '向新添加行的SjID列添加内容
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjZ") = Zj1
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("ScRQ") = Now()
Dim AddID_str As String = "select * from LS where SjID='AddID' "
Dim AddID_Ra As New OleDbDataAdapter(AddID_str, CnnStr)
Dim AddID_Set As New DataSet
Dim Add_Tb As New DataTable("AddId_Tb")
Dim Cbdr As New OleDbCommandBuilder(AddID_Ra) '自动生成SQL更新DATASET到数据源
AddID_Ra.Fill(Add_Tb)
AddID_Set.Tables.Add(Add_Tb)
Dim Add As Integer, I As Integer, ZJ As Integer, Zj1 As String
Add = AddID_Set.Tables("AddId_Tb").Rows.Count
I = Add - 1
Bm = AddID_Set.Tables("AddId_Tb").Rows(I)("SjZ") '读取编号
ZJ = Int(MyDES.DesJieM(Bm, Ma)) '编号解密
ZJ = ZJ + 1 '编号+1'
Zj1 = MyDES.DesJiaM(ZJ.ToString, Ma) '编号加密'
AddID_Set.Tables("AddID_Tb").Rows.Add() '添加一行'
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjID") = "AddID" '向新添加行的SjID列添加内容
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjZ") = Zj1
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("ScRQ") = Now()
AddID_Ra.Update(AddID_Set, "AddId_Tb") '更新数据'
AddID_Set.Clear()
Add_Tb.Clear() AddID_Set.Clear()
Add_Tb.Clear()
-------时而发生保存的信息未能+1 但大部分情况下是可以的,是怎么回事?感觉 AddID_Ra.Update(AddID_Set, "AddId_Tb") 并不可靠,请帮我改一下.
2,再有是对dataset中的数据进行修改时使用 AddID_Ra.Update(AddID_Set, "AddId_Tb") '
更新数据后,再次 AddID_Ra.Update(AddID_Set, "AddId_Tb") 时就会出现并发情错误,这是怎么回事,应该怎么样避免?
Dim AddID_Ra As New OleDbDataAdapter(AddID_str, CnnStr)
Dim AddID_Set As New DataSet
Dim Add_Tb As New DataTable("AddId_Tb")
Dim Cbdr As New OleDbCommandBuilder(AddID_Ra) '自动生成SQL更新DATASET到数据源
AddID_Ra.Fill(Add_Tb)
AddID_Set.Tables.Add(Add_Tb)
Dim Add As Integer, I As Integer, ZJ As Integer, Zj1 As String
Add = AddID_Set.Tables("AddId_Tb").Rows.Count
I = Add - 1
Bm = AddID_Set.Tables("AddId_Tb").Rows(I)("SjZ") '读取编号
ZJ = Int(MyDES.DesJieM(Bm, Ma)) '编号解密
ZJ = ZJ + 1 '编号+1'
Zj1 = MyDES.DesJiaM(ZJ.ToString, Ma) '编号加密'
AddID_Set.Tables("AddID_Tb").Rows.Add() '添加一行'
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjID") = "AddID" '向新添加行的SjID列添加内容
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjZ") = Zj1
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("ScRQ") = Now()
Dim AddID_str As String = "select * from LS where SjID='AddID' "
Dim AddID_Ra As New OleDbDataAdapter(AddID_str, CnnStr)
Dim AddID_Set As New DataSet
Dim Add_Tb As New DataTable("AddId_Tb")
Dim Cbdr As New OleDbCommandBuilder(AddID_Ra) '自动生成SQL更新DATASET到数据源
AddID_Ra.Fill(Add_Tb)
AddID_Set.Tables.Add(Add_Tb)
Dim Add As Integer, I As Integer, ZJ As Integer, Zj1 As String
Add = AddID_Set.Tables("AddId_Tb").Rows.Count
I = Add - 1
Bm = AddID_Set.Tables("AddId_Tb").Rows(I)("SjZ") '读取编号
ZJ = Int(MyDES.DesJieM(Bm, Ma)) '编号解密
ZJ = ZJ + 1 '编号+1'
Zj1 = MyDES.DesJiaM(ZJ.ToString, Ma) '编号加密'
AddID_Set.Tables("AddID_Tb").Rows.Add() '添加一行'
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjID") = "AddID" '向新添加行的SjID列添加内容
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("SjZ") = Zj1
AddID_Set.Tables("AddID_Tb").Rows(I + 1)("ScRQ") = Now()
AddID_Ra.Update(AddID_Set, "AddId_Tb") '更新数据'
AddID_Set.Clear()
Add_Tb.Clear() AddID_Set.Clear()
Add_Tb.Clear()
-------时而发生保存的信息未能+1 但大部分情况下是可以的,是怎么回事?感觉 AddID_Ra.Update(AddID_Set, "AddId_Tb") 并不可靠,请帮我改一下.
2,再有是对dataset中的数据进行修改时使用 AddID_Ra.Update(AddID_Set, "AddId_Tb") '
更新数据后,再次 AddID_Ra.Update(AddID_Set, "AddId_Tb") 时就会出现并发情错误,这是怎么回事,应该怎么样避免?