Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Radhika Vyas 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

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);
 
Share this answer
 
Comments
Radhika Vyas 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 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
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......
 
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