几天来我一直在努力解决这个问题,并且无法找出以下代码有什么问题。当我单击按钮进行更新时,没有任何更新。顺便说一句,我正在使用 html 表格来显示客户的信息,然后使用表格中的那些文本框来更新字段。但是 SQL 更新语句不起作用。这是代码:
Protected Sub btnUpdate_Click(sender As Object, e As System.EventArgs) Handles btnUpdate.Click
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim ID As Integer
Dim mySQLString As String, strFirstName As String, strLastName As String, strPhone As String, strEmail, strComment As String, Employee As String, DateCalled, TimeCalled, DateEdited As datetime
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\wfccdb\datagridview\app_data\t3corp.mdb;")
myConnection.Open()
ID = Request.QueryString.Item("r")
Employee = tbEMP.Text
strFirstName = tbFname.Text
strLastName = tbLname.Text
strPhone = tbPhone.Text
strEmail = tbEmail.Text
DateCalled = Convert.ToDateTime(tbDateCalled.Text)
TimeCalled = Convert.ToDateTime(tbTimeCalled.Text)
strComment = tbComment.Text
DateEdited = Now
mySQLString = "UPDATE customers SET Employee='" + Employee + "', FirstName='" + strFirstName + "', LastName='" + strLastName + "', Phone='" + strPhone + "', Email='" + strEmail + "', DateCalled='" + DateCalled + "', " + _
"TimeCalled='" + TimeCalled + "', Comment='" + strComment + "', DateEdited='" + DateEdited + "' WHERE ReferenceID=" & Val(ID) & ""
myCommand = New OleDbCommand
myCommand.Connection = myConnection
myCommand.CommandText = mySQLString
myCommand.ExecuteNonQuery()
myConnection.Close()
Response.Redirect("ViewEditRecords.aspx?r=" + Request.QueryString.Item("r"))
End Sub