Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
What's the problem in this code:
C#
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
                                                                        + Application.StartupPath + "/Database/DB.accdb;Jet OLEDB:Database Password=123");
OleDbCommand cmd = new OleDbCommand("update tblUP Set Password=@UP,UserType=@UT,FirstName=@FN,LastName=@LN where UserName=@UN",cn);
cmd.Parameters.AddWithValue("@UP", txtUP.Text);
cmd.Parameters.AddWithValue("@UT", chkUT.Checked);
cmd.Parameters.AddWithValue("@FN", txtFN.Text);
cmd.Parameters.AddWithValue("@LN", txtLN.Text);
cmd.Parameters.AddWithValue("@UN", txtUN.Text);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();

compiler answer: syntax error.
thanks.
Posted
Comments
Michael_Davies 1-Aug-15 2:56am    
Compiler usually tells you which line it does not just say there is a syntax error.

Which line gives the error?
sasanka sekhar panda 1-Aug-15 3:02am    
what the code you posted i do not find any syntax error.. Please elaborate your question
sasanka sekhar panda 1-Aug-15 3:15am    
No, I tried your code in vs 2013 there was no syntax error...In which line you got the error..
Michael_Davies 1-Aug-15 3:20am    
The only possible error is the use of / in a directory name on a Windows system it should be \
Wendelius 1-Aug-15 3:32am    
If the OP has used \ in the original code instead of / ,it would actually cause syntactical errors unless a verbatim string is used. So that could be the reason...

use cn.open before the update query
 
Share this answer
 
Comments
Wendelius 1-Aug-15 3:54am    
Why should the OP do that?
hi everyone.
i found the problem;
just, change the bellow.
Password=@UP -------------> Pass=@UP
thanks.
 
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