Reagar ding oledb异常未处理 [英] Reagar ding oledb exception was unhandled

查看:97
本文介绍了Reagar ding oledb异常未处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的例外是**查询值和目标字段的数量不相同." **
我正在使用Windows7,VS2010-c#.net4.0和MS-Access2010数据库.
请让我知道如何解决此错误.我的代码如下

Hi
my exception is **"Number of query values and destination fields are not the same."**
i am using Windows7,VS2010-c#.net4.0 and MS-Access2010 database.
Please let me know how to resolve this error. My code is as follows

{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\baswaraj\\Documents\\Database1.accdb");
 string query = "insert into information values('" + textBox1.Text + "'," + textBox2.Text + "," + textBox3.Text + ")";
            OleDbCommand cmd = new OleDbCommand(query, con);
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
}



代码格式为



Code formatted

推荐答案

否.您尝试通过查询字符串插入的项目的数量,并且Information表中的列数不相同.这就是原因.

因此,请尝试通过查询字符串在信息表中插入相同数量的列值.

希望对您有所帮助.
No. of item you are trying to insert via query string and number of column in the Information table is not same. And this the reason.

So try to insert same no of column values into Information table via query string.

Hope it helps.


按如下所示修改查询
Modify the query as follow
string query="insert into information([First field name],[Second field name],[Third field name]) values('"+textbox1.Text+"',"+textbox2.Text+","+textbox3.Text+")";


这篇关于Reagar ding oledb异常未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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