我们有一个时髦的问题,我们有vb.net应用程序,通过选择查询到oracle获取可更新的数据阅读器。我们使用ODBC进行连接。
我们有两个表F4201和f4211 01表是标题,11是详细信息。
我们对事务中的两个表都有更新,但我们看到在某些看似随机的情况下,只有细节得到更新,而标题却没有。例如,请参阅下面的代码。
Dim cnnE1 As OdbcConnection
Dim txn As OdbcTransaction
Dim E1Database As String = My.Settings.SettingValue("E1Database")
Try
cnnE1 = DbConn.CreateConnection(My.Settings.E1Conn)
cnnE1.Open()
Catch ex As Exception
Return ProcessReturnType.Fail
End Try
txn = cnnE1.BeginTransaction
ssql = "SELECT * FROM " & E1Database & ".F4201 WHERE SHDOCO = " & tmpTrafficOrder
If Not DbConn.GetUpdateableDataAdapter(ssql, cnnE1, daSales_Header, txn) Then
txn.Rollback()
Dispose_ODBC_Connection(cnnE1)
Return ProcessReturnType.Fail
End If
If daSales_Header.Fill(dsSales_Header) > 0 Then
'If Sales Order Header has matching records then grab the Sales Order Detail records as well
'ssql = "SELECT * FROM " & E1Database & ".F4211 WHERE LTRIM(SDKCOO) = '" & tmpDemandLocation & "' AND SDDOCO = " & tmpTrafficOrder
ssql = "SELECT * FROM " & E1Database & ".F4211 WHERE SDDOCO = " & tmpTrafficOrder
If Not DbConn.GetUpdateableDataAdapter(ssql, cnnE1, daSales_Detail, txn) Then
txn.Rollback()
Dispose_ODBC_DataAdapter(daSales_Header)
Dispose_ODBC_Connection(cnnE1)
Return ProcessReturnType.Fail
End If
end if
'This function uses sql to map XML elements from the file we receive to the Oracle Field and updated the DR with the information.
'Testing shows the DR is updated with the new values after this runs
If Not oMapping.MapObjectToDataRow(fileId, ApptNotification, drSales_Header, "ApptNotif.SalesHeader", mapSubSet, My.Settings.InterfaceType) Then
txn.Rollback()
Dispose_ODBC_DataAdapter(daSales_Header)
Dispose_ODBC_Connection(cnnE1)
Return ProcessReturnType.Fail
End If
daSales_Header.Update(dsSales_Header)
dsSales_Header.AcceptChanges()
'Now time for details.
If daSales_Detail.Fill(dsSales_Detail) > 0 Then
For Each drSales_Detail As DataRow In dsSales_Detail.Tables(0).Rows
If Not oMapping.MapObjectToDataRow(fileId, ApptNotification, drSales_Detail, "ApptNotif.SalesDetail", mapSubSet, My.Settings.InterfaceType) Then
txn.Rollback()
Dispose_ODBC_DataAdapter(daSales_Header)
Dispose_ODBC_DataAdapter(daSales_Detail)
Dispose_ODBC_Connection(cnnE1)
Return ProcessReturnType.Fail
End If
daSales_Detail.Update(dsSales_Detail)
dsSales_Detail.AcceptChanges()
next
Else
txn.Rollback()
Dispose_ODBC_Connection(cnnE1)
Return ProcessReturnType.Skip
End If
txn.Commit()
txn.Dispose()
cnnE1.Close()
cnnE1.Dispose()
答案 0 :(得分:0)
经过进一步调查后,我们发现这不是错误的交易,它正确地更新了表,有一个单独的进程正在改变值。