Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: (untagged)
HI Everybody here is my code..If I try with commented part its giving exception Somehting as Incorrect Update Syntax..please help...If i comment that query without password its working fine... try { string path1 = System.Configuration.ConfigurationManager.AppSettings.Get("databasepath"); OleDbConnection con = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + path1); con.Open(); // OleDbCommand cmd = new OleDbCommand("UPDATE codefixermp_tblMembers SET Firstname=@Firstname, Lastname=@Lastname,Address=@Address,City=@City,County=@County,Password=@Password,Comments=@Comments WHERE ID=" + uID.Text + "", con); OleDbCommand cmd = new OleDbCommand("UPDATE codefixermp_tblMembers SET Firstname=@Firstname, Lastname=@Lastname,Address=@Address,City=@City,County=@County,Comments=@Comments WHERE ID=" + uID.Text + "", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@Firstname", txtFirstName.Text); cmd.Parameters.AddWithValue("@Lastname", txtLastName.Text); cmd.Parameters.AddWithValue("@Address", txtAddress.Text); cmd.Parameters.AddWithValue("@City", txtCity.Text); cmd.Parameters.AddWithValue("@County", txtState.Text); //cmd.Parameters.AddWithValue("@Password", txtPassword.Text); cmd.Parameters.AddWithValue("@Comments", txtcomments.Text); cmd.ExecuteNonQuery(); con.Close(); con = null; } catch (Exception ex) { txtFirstName.Text = ex.Message; }
Posted 6-Sep-12 22:12pm
Comments
Radhika Vyas at 11-Sep-12 2:37am
   
Hi everybody,
I have found a new thing from my issue...I dont know why my update is working fine if i rename my password field..something like 'password1'..Is MS-Access wont allow to update if the field name is 'password'..if anyone has idea please help
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi Radhika
 
YOUR COMMENTED UPDATE STATEMENT , ONLY THE SINGLE QUOTES ARE MISSING ,USE THE BELOW LINE AND CHECK IF THE PROBLEM IS SOLVED
 
           OleDbCommand cmd = new OleDbCommand("UPDATE codefixermp_tblMembers SET Firstname=@Firstname, Lastname=@Lastname,Address=@Address,City=@City,County=@County,Password=@Password,Comments=@Comments WHERE ID='" + uID.Text + "'", con); 
  Permalink  
Comments
Radhika Vyas at 7-Sep-12 5:16am
   
Hi It didn't work..ur single quote... 'Syntax error in UPDATE statement.' This exception only am getting........
Radhika Vyas at 7-Sep-12 5:25am
   
But the uncommented update statement is working fine Sir..Is there any limit for number of fields to update...i added three more fields also they are also getting updated...only this password field if i add na am getting exception
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

yes,I resolve my issue..'Password' is a restricted key in ms-access.So,its not getting updated...We need to place all the fields with in square-bracket then it works..like
 
"UPDATE codefixermp_tblMembers SET [Firstnam]e=@Firstname, [Lastname]=@Lastname,[Address]=@Address,[City]=@City,[County]=@County,[Password]=@Password......
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100