使用存储过程在MySql数据库中插入数据时出错 [英] error in inserting data in MySql database using Stored procedure
本文介绍了使用存储过程在MySql数据库中插入数据时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
con = new OdbcConnection("DRIVER={MySQL ODBC 5.1 Driver};SERVER=192.168.0.10;DATABASE=PDF_Data;UID=heman;PASSWORD=harjeet;OPTION=3");
con.Open();
cmd = new OdbcCommand("insert_pdf_data", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ID", 1);
cmd.Parameters.AddWithValue("@BatchName",DDBatch.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@ClientNm", DDClient.SelectedValue.ToString());
cmd.ExecuteNonQuery();
con.Close();
推荐答案
由于您没有说错,所以我猜@ID参数应该是整数而不是字符串.如果在代码周围放置try/catch
块,则将确切找出问题所在.
Since you didn''t say WHAT was wrong, I''m going to guess that the @ID parameter should be an integer instead of a string. If you put a try/catch
block around the code, you''ll find out EXACTLY what is wrong.
这篇关于使用存储过程在MySql数据库中插入数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文