Try
With com
.CommandType = CommandType.Text
.CommandText = "TRUNCATE TABLE BOOKTEMP"
.Connection = Conn
.Transaction = tr
.ExecuteNonQuery()
.CommandText = "INSERT INTO BOOKTEMP SELECT * FROM BOOK WHERE COMCODE = '" & tmpComCode & "'"
.ExecuteNonQuery()
End With
tr.Commit()
Catch
MessageBox.Show(Err.Description, "The error", MessageBoxButtons.OK, MessageBoxIcon.Error)
tr.Rollback()
Exit Sub
End Try
1. ถ้าปัญหามันเกิดจากโค้ดส่วนที่ว่าจริงๆ ก็ลองไม่ต้องใช้ Transaction
2. ตรวจสอบว่า INSERT INTO BOOKTEMP SELECT * FROM BOOK WHERE COMCODE = 'XXXX' ใช้งานได้จริง
Code (VB.NET)
Try
With com
.CommandType = CommandType.Text
.CommandText = "TRUNCATE TABLE BOOKTEMP"
.Connection = Conn
.ExecuteNonQuery()
.CommandText = "INSERT INTO BOOKTEMP SELECT * FROM BOOK WHERE COMCODE = '" & tmpComCode & "'"
.ExecuteNonQuery()
End With
Catch
MessageBox.Show(Err.Description, "The error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try