-3
我在更新記錄時遇到問題。我不知道什麼似乎是問題。點擊更新後,似乎沒有出現錯誤。這是我的代碼。更新記錄失敗
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Charles\Documents\Database1.accdb"
Dim cmd As String
cmd = "UPDATE Employee SET EmployeeName = @eName, SSS = @SSS, TIN = @TIN, ED = @ED, Salary = @Salary WHERE EmployeeName = @eName"
Dim cmdUpdate As New OleDbCommand(cmd, conn)
enableTxtBox()
If btnEdit.Text = "Edit" Then
btnEdit.Text = "Update"
Else
btnEdit.Text = "Edit"
Try
conn.Open()
cmdUpdate.Parameters.AddWithValue("@eName", txtName.Text)
cmdUpdate.Parameters.AddWithValue("@SSS", txtSSS.Text)
cmdUpdate.Parameters.AddWithValue("@TIN", txtTIN.Text)
cmdUpdate.Parameters.AddWithValue("@ED", dtpED)
cmdUpdate.Parameters.AddWithValue("@Salary", txtSalary.Text)
cmdUpdate.ExecuteNonQuery()
fillListView()
clearAll()
disableTxtBox()
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End If
您是說'UPDATE'失敗,但您聲稱沒有錯誤報告在任何地方。那麼你怎麼知道它失敗了? – stakx 2014-09-13 06:57:53
對不起,我上週末正在度假,所以我無法回覆......正如你所看到的,我試圖捕捉是否會出現任何錯誤。「但是」在編輯某個記錄時,該記錄看起來並不像要更新...但沒有錯誤顯示,所以我真的不知道什麼代碼即時消失 – NewbieVB 2014-09-15 01:20:18