Click here to Skip to main content
15,903,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got syntax error on my update statement. I am using Visual Basic 2008. Please do help me for I need to finish this asap. Thanks in advance for those who will give their comments..

VB
Imports System.Data

Imports System.Data.OleDb


Public Class ControlFile
Dim cnnOLEDB As New OleDbConnection

Dim cmdOLEDB As New OleDbCommand

Dim cmdInsert As New OleDbCommand

Dim cmdUpdate As New OleDbCommand

Dim cmdRemove As New OleDbCommand

Dim strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= E:\VB Programs\AIS.accdb"

Private Sub ControlFile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

cnnOLEDB.ConnectionString = strConnectionString

cnnOLEDB.Open()

End Sub

   Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click

        If OrganizationTextBox.Text <> "" And CalendarYearTextBox.Text <> "" Then

            cmdUpdate.CommandText = "UPDATE ControlFile SET " & _
            "Organization = '" & OrganizationTextBox.Text & "', " & _
            "CalendarYear = '" & CalendarYearTextBox.Text & "', " & _
            "EarningsControl = '" & EarningsControlTextBox.Text & "', " & _
            "EarningsAccount = '" & EarningsAccountTextBox.Text & "', " & _
            "RetainedControl = '" & RetainedControlTextBox.Text & "', " & _
            "RetainedAccount = '" & RetainedAccountTextBox.Text & "', " & _
            "DebitCredit = '" & DebitCreditTextBox.Text & "', " & _
            "CurrentPeriod = '" & CurrentPeriodTextBox.Text & "', " & _
            "WHERE Organization = '" & OrganizationTextBox.Text & "'"
Posted
Updated 11-Oct-13 19:21pm
v2

Your last updating column, CurrentPeriod, shouldn't have a comma at the end.

No comma should exist in between your last update item and the WHERE clause.
 
Share this answer
 
Comma exists before the where condition so only it will show erro please remove that one

SQL
"CurrentPeriod = '" & CurrentPeriodTextBox.Text & "' " & _
           "WHERE Organization = '" & OrganizationTextBox.Text & "'"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900