关于ms访问中的更新问题 [英] Regarding Update problem in ms access

查看:99
本文介绍了关于ms访问中的更新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在更新ms access中的记录时遇到问题.我在另一个正常工作的项目中写了相同的查询,但是在另一个项目中却出现了类似
的错误 更新语句中的语法错误"

请给我一个解决方案,这里是查询


字符串ConnectionString = ConfigurationManager.AppSettings ["myconstring"];
OleDbConnection con =新的OleDbConnection();
con.ConnectionString = ConnectionString;
con.Open();
字符串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()+"''其中cust_num =" + txt_custnum.Text.Trim()+'' ;
OleDbCommand cmd_updatecust =新的OleDbCommand(query_updatecust,con);
int val = cmd_updatecust.ExecuteNonQuery();
con.Close();

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();

推荐答案

将query_updatecus输出到调试窗口并直接在数据库上执行SQL语句,这样应该可以更好地了解查询失败的地方.....可能是数据类型不匹配的问题
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


这篇关于关于ms访问中的更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆