I got Syntax Error on my Update command.. Please do help me for I need to finish this

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lanp
    New Member
    • Oct 2013
    • 1

    I got Syntax Error on my Update command.. Please do help me for I need to finish this

    Code:
    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 & "'"
    Last edited by Rabbit; Oct 11 '13, 11:47 PM. Reason: Please use [CODE] and [/CODE]tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    It would help to have the full error message, but the most likely cause is that you have an extra comma in your SQL string before the where clause.

    Comment

    Working...