These are my codes. It does not go through. I am having error in the UPDATE.
After clicking Edit, do my edit, and when i click on Save and choose "Yes";
that is where the UPDATE error occurs.
I need help.
Thanks.
Watertubig
-----------------------------------------------------------------------
Public Class Frm_StealStreet
Private Sub Frm_StealStreet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'StealStreetDataSet.Employees' table. You can move, or remove it, as needed.
Me.EmployeesTableAdapter.Fill(Me.StealStreetDataSet.Employees)
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub EditToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditToolStripButton.Click
TBx_EmplLast.ReadOnly = False
TBx_EmplFirst.ReadOnly = False
TBx_EmplAddress.ReadOnly = False
TBx_EmplCity.ReadOnly = False
TBx_EmplState.ReadOnly = False
TBx_EmplZip.ReadOnly = False
TBx_EmplPhone1.ReadOnly = False
TBx_EmplPhone2.ReadOnly = False
TBx_EmplFaxNo.ReadOnly = False
TBx_EmplEmlAddress.ReadOnly = False
TBx_EmplPosition.ReadOnly = False
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
Dim v_result As Integer
v_result = MsgBox("Do you want to save record?", vbYesNo)
If v_result = MsgBoxResult.Yes Then
Dim v_EmplCode As String
Dim v_EmplLast As String
Dim v_EmplFirst As String
Dim v_EmplAddress As String
Dim v_EmplCity As String
Dim v_EmplState As String
Dim v_EmplZip As String
Dim v_EmplPhone1 As String
Dim v_EmplPhone2 As String
Dim v_EmplFaxNo As String
Dim v_EmplEmlAddress As String
Dim v_EmplPosition As String
Dim v_ConnectString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Joseph\Documents\MS Access 2007\StealStreet.accdb"
Dim v_strupdate As String
v_strupdate = "UPDATE Employees " & _
"SET LastName = v_EmplLast, FirstName = v_EmplFirst, " & _
"Address = v_EmplAddress, City = v_EmplCity, " & _
"State = v_EmplState, Zip_Code = v_EmplZip, " & _
"Phone_No1 = v_EmplPhone1, Phone_No2 = v_EmplPhone2, Fax_No = v_EmplFaxNo, " & _
"Email_Address = v_EmplEmlAddress, Position = v_EmplPosition " & _
"WHERE (Employee_Code = v_EmplCode)"
Dim v_comBldr As New OleDb.OleDbCommand(v_strupdate)
v_EmplCode = TBx_EmplCode.Text
v_EmplLast = TBx_EmplLast.Text
v_EmplFirst = TBx_EmplFirst.Text
v_EmplAddress = TBx_EmplAddress.Text
v_EmplCity = TBx_EmplCity.Text
v_EmplState = TBx_EmplState.Text
v_EmplZip = TBx_EmplZip.Text
v_EmplPhone1 = TBx_EmplPhone1.Text
v_EmplPhone2 = TBx_EmplPhone2.Text
v_EmplFaxNo = TBx_EmplFaxNo.Text
v_EmplEmlAddress = TBx_EmplAddress.Text
v_EmplPosition = TBx_EmplPosition.Text
v_comBldr.Connection = New OleDb.OleDbConnection(v_ConnectString)
v_comBldr.Connection.Open()
v_comBldr.ExecuteNonQuery()
v_comBldr.Connection.Close()
MsgBox("Record is saved!")
Else
MsgBox("Record not saved!")
End If
TBx_EmplLast.ReadOnly = True
TBx_EmplFirst.ReadOnly = True
TBx_EmplAddress.ReadOnly = True
TBx_EmplCity.ReadOnly = True
TBx_EmplState.ReadOnly = True
TBx_EmplZip.ReadOnly = True
TBx_EmplPhone1.ReadOnly = True
TBx_EmplPhone2.ReadOnly = True
TBx_EmplFaxNo.ReadOnly = True
TBx_EmplEmlAddress.ReadOnly = True
TBx_EmplPosition.ReadOnly = True
End Sub
End Class
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message=Syntax error in UPDATE statement.
Source=Microsoft Office Access Database Engine
After clicking Edit, do my edit, and when i click on Save and choose "Yes";
that is where the UPDATE error occurs.
I need help.
Thanks.
Watertubig
-----------------------------------------------------------------------
Public Class Frm_StealStreet
Private Sub Frm_StealStreet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'StealStreetDataSet.Employees' table. You can move, or remove it, as needed.
Me.EmployeesTableAdapter.Fill(Me.StealStreetDataSet.Employees)
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub EditToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditToolStripButton.Click
TBx_EmplLast.ReadOnly = False
TBx_EmplFirst.ReadOnly = False
TBx_EmplAddress.ReadOnly = False
TBx_EmplCity.ReadOnly = False
TBx_EmplState.ReadOnly = False
TBx_EmplZip.ReadOnly = False
TBx_EmplPhone1.ReadOnly = False
TBx_EmplPhone2.ReadOnly = False
TBx_EmplFaxNo.ReadOnly = False
TBx_EmplEmlAddress.ReadOnly = False
TBx_EmplPosition.ReadOnly = False
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
Dim v_result As Integer
v_result = MsgBox("Do you want to save record?", vbYesNo)
If v_result = MsgBoxResult.Yes Then
Dim v_EmplCode As String
Dim v_EmplLast As String
Dim v_EmplFirst As String
Dim v_EmplAddress As String
Dim v_EmplCity As String
Dim v_EmplState As String
Dim v_EmplZip As String
Dim v_EmplPhone1 As String
Dim v_EmplPhone2 As String
Dim v_EmplFaxNo As String
Dim v_EmplEmlAddress As String
Dim v_EmplPosition As String
Dim v_ConnectString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Joseph\Documents\MS Access 2007\StealStreet.accdb"
Dim v_strupdate As String
v_strupdate = "UPDATE Employees " & _
"SET LastName = v_EmplLast, FirstName = v_EmplFirst, " & _
"Address = v_EmplAddress, City = v_EmplCity, " & _
"State = v_EmplState, Zip_Code = v_EmplZip, " & _
"Phone_No1 = v_EmplPhone1, Phone_No2 = v_EmplPhone2, Fax_No = v_EmplFaxNo, " & _
"Email_Address = v_EmplEmlAddress, Position = v_EmplPosition " & _
"WHERE (Employee_Code = v_EmplCode)"
Dim v_comBldr As New OleDb.OleDbCommand(v_strupdate)
v_EmplCode = TBx_EmplCode.Text
v_EmplLast = TBx_EmplLast.Text
v_EmplFirst = TBx_EmplFirst.Text
v_EmplAddress = TBx_EmplAddress.Text
v_EmplCity = TBx_EmplCity.Text
v_EmplState = TBx_EmplState.Text
v_EmplZip = TBx_EmplZip.Text
v_EmplPhone1 = TBx_EmplPhone1.Text
v_EmplPhone2 = TBx_EmplPhone2.Text
v_EmplFaxNo = TBx_EmplFaxNo.Text
v_EmplEmlAddress = TBx_EmplAddress.Text
v_EmplPosition = TBx_EmplPosition.Text
v_comBldr.Connection = New OleDb.OleDbConnection(v_ConnectString)
v_comBldr.Connection.Open()
v_comBldr.ExecuteNonQuery()
v_comBldr.Connection.Close()
MsgBox("Record is saved!")
Else
MsgBox("Record not saved!")
End If
TBx_EmplLast.ReadOnly = True
TBx_EmplFirst.ReadOnly = True
TBx_EmplAddress.ReadOnly = True
TBx_EmplCity.ReadOnly = True
TBx_EmplState.ReadOnly = True
TBx_EmplZip.ReadOnly = True
TBx_EmplPhone1.ReadOnly = True
TBx_EmplPhone2.ReadOnly = True
TBx_EmplFaxNo.ReadOnly = True
TBx_EmplEmlAddress.ReadOnly = True
TBx_EmplPosition.ReadOnly = True
End Sub
End Class
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message=Syntax error in UPDATE statement.
Source=Microsoft Office Access Database Engine