我有代码将 mydatatable 中的信息保存到数据库和我的审计文件中,我正在使用下面的代码。但是代码的第一部分效果很好,但第二部分没有做这项工作。为什么相同的代码不适用于另一个数据库。它没有将数据表插入到审计文件中
'**************************************************************************************************************************************************
'********************* SAVE PRODUCT RAW MATERIAL DETAILS IN THE GRIDVIEW ******************************************************
Dim myConn As OleDbConnection = frmLogIn.Conn
Dim oledbCmdBuilder As OleDbCommandBuilder
Dim changes As DataTable
Dim sql As String = "select * from ProductRawMaterial"
Dim oledbAdapter As OleDbDataAdapter = New OleDbDataAdapter(sql, myConn)
'Try
oledbCmdBuilder = New OleDbCommandBuilder(oledbAdapter)
changes = myTable.GetChanges()
oledbCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges
If changes IsNot Nothing Then
oledbAdapter.Update(myTable)
End If
'myTable.AcceptChanges()
myConn.Close()
'Catch ex As Exception
' MsgBox(ex.ToString)
'End Try
'***************************************************************************************************************************************************
'********************************************************* SAVING TO AUDIT ****************************************************************
Dim myKonn As OleDbConnection = frmLogIn.Connn
Dim oledbCmdBuilderAudit As OleDbCommandBuilder
'Dim changes As DataTable
Dim sqlAudit As String = "select * from ProductRawMaterial"
Dim oledbAdapterAudit As OleDbDataAdapter = New OleDbDataAdapter(sqlAudit, myKonn)
'Try
oledbCmdBuilderAudit = New OleDbCommandBuilder(oledbAdapterAudit)
'changes = myTable.GetChanges()
oledbCmdBuilderAudit.ConflictOption = ConflictOption.OverwriteChanges
If changes IsNot Nothing Then
oledbAdapterAudit.Update(myTable)
End If
myTable.AcceptChanges()
myKonn.Close()
'Catch ex As Exception
' MsgBox(ex.ToString)
'End Try