Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I had a problem in updating a record in ms access.I wrote the same query in another project which is working correctly.But in another project it is giving error like
'Syntax error in Update Statement'

Please give me a solution for that,here is the query


string ConnectionString = ConfigurationManager.AppSettings["myconstring"];
OleDbConnection con = new OleDbConnection();
con.ConnectionString = ConnectionString;
con.Open();
string query_updatecust = "update tbl_customer set cust_name='" + txt_customer_name.Text.Trim() + "', cust_opno='" + txt_opno.Text.Trim() + "', addr1='" + txt_address1.Text.Trim() + "', addr2='" + txt_address2.Text.Trim() + "', addr3='" + txt_address3.Text.Trim() + "', contact_no='" + txt_contactno.Text.Trim() + "', note='" + txt_note.Text.Trim() + "' where cust_num='" + txt_custnum.Text.Trim() + "'";
OleDbCommand cmd_updatecust = new OleDbCommand(query_updatecust, con);
int val = cmd_updatecust.ExecuteNonQuery();
con.Close();
Posted
Comments
John Y. 26-Sep-11 11:43am    
Can you please output what the string actually reads?
Arun Kumar K S 26-Sep-11 12:13pm    
use single courts only in Text type and remove single courts from number

1 solution

Output the query_updatecus to the debug window and execute the SQL statement directly on the database and this should give a better idea where the query fails.....May be a data type mismatch issue
 
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