我无法修复此空引用异常
Dim Conn As New OleDb.OleDbConnection
Dim Trans As OleDb.OleDbTransaction
Try
' create the stream writer object
Dim FS As New System.IO.StreamReader(FileName)
' open DB connection and start a transaction
Dim Tmp As New POSDSTableAdapters.ItemsTableAdapter
Conn.ConnectionString = Tmp.Connection.ConnectionString
Conn.Open()
Trans = Conn.BeginTransaction
' clear all tables
Dim CMD As New OleDb.OleDbCommand
CMD.CommandText = " delete from ReciptDetails"
CMD.Connection = Conn
CMD.Transaction = Trans
CMD.ExecuteNonQuery()
CMD.Dispose()
CMD = New OleDb.OleDbCommand
CMD.CommandText = " delete from Recipts"
CMD.Connection = Conn
CMD.Transaction = Trans
CMD.ExecuteNonQuery()
CMD.Dispose()
CMD = New OleDb.OleDbCommand
CMD.CommandText = " delete from items"
CMD.Connection = Conn
CMD.Transaction = Trans
CMD.ExecuteNonQuery()
CMD.Dispose()
CMD = New OleDb.OleDbCommand
CMD.CommandText = " delete from RestorantTable"
CMD.Connection = Conn
CMD.Transaction = Trans
CMD.ExecuteNonQuery()
CMD.Dispose()
CMD = New OleDb.OleDbCommand
CMD.CommandText = " delete from [Values]"
CMD.Connection = Conn
CMD.Transaction = Trans
CMD.ExecuteNonQuery()
CMD.Dispose()
' load the tables
If Not LoadTableFromBackup(Conn, Trans, FS, "RestorantTable") Then
Trans.Rollback()
Conn.Close()
FS.Close()
Return False
End If
If Not LoadTableFromBackup(Conn, Trans, FS, "Values") Then
Trans.Rollback()
Conn.Close()
FS.Close()
Return False
End If
If Not LoadTableFromBackup(Conn, Trans, FS, "items") Then
Trans.Rollback()
Conn.Close()
FS.Close()
Return False
End If
If Not LoadTableFromBackup(Conn, Trans, FS, "Recipts") Then
Trans.Rollback()
Conn.Close()
FS.Close()
Return False
End If
If Not LoadTableFromBackup(Conn, Trans, FS, "ReciptDetails") Then
Trans.Rollback()
Conn.Close()
FS.Close()
Return False
End If
FS.Close()
Trans.Commit()
Conn.Close()
Return True
Catch ex As Exception
Trans.Rollback()
Conn.Close()
Return False
End Try
End Function