By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,066 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,066 IT Pros & Developers. It's quick & easy.

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

P: 1
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2.  
  3. Imports System.Data.OleDb
  4.  
  5.  
  6. Public Class ControlFile
  7.     Dim cnnOLEDB As New OleDbConnection
  8.  
  9.     Dim cmdOLEDB As New OleDbCommand
  10.  
  11.     Dim cmdInsert As New OleDbCommand
  12.  
  13.     Dim cmdUpdate As New OleDbCommand
  14.  
  15.     Dim cmdRemove As New OleDbCommand
  16.  
  17.     Dim strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= E:\VB Programs\AIS.accdb"
  18.  
  19. Private Sub ControlFile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  20.  
  21.         cnnOLEDB.ConnectionString = strConnectionString
  22.  
  23.         cnnOLEDB.Open()
  24.  
  25. End Sub
  26.  
  27.  
  28. Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
  29.  
  30. If OrganizationTextBox.Text <> "" And CalendarYearTextBox.Text <> "" Then
  31.  
  32.  
  33. cmdUpdate.CommandText = "UPDATE ControlFile SET " & _
  34. "Organization = '" & OrganizationTextBox.Text & "', " & _
  35. "CalendarYear = '" & CalendarYearTextBox.Text & "', " & _
  36. "EarningsControl = '" & EarningsControlTextBox.Text & "', " & _
  37. "EarningsAccount = '" & EarningsAccountTextBox.Text & "', " & _
  38. "RetainedControl = '" & RetainedControlTextBox.Text & "', " & _
  39. "RetainedAccount = '" & RetainedAccountTextBox.Text & "', " & _
  40. "DebitCredit = '" & DebitCreditTextBox.Text & "', " & _
  41. "CurrentPeriod = '" & CurrentPeriodTextBox.Text & "', " & _
  42. "WHERE Organization = '" & OrganizationTextBox.Text & "'"
Oct 11 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,383
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.
Oct 11 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.