下面错误是什么问题!
Server Error in '/school' Application.
--------------------------------------------------------------------------------You have an error in your SQL syntax near 'Set honor_name = 'dsb125' ,honor_date = '2005-04-26 00:00:00' ,honor_grade = '20' at line 1
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax near 'Set honor_name = 'dsb125' ,honor_date = '2005-04-26 00:00:00' ,honor_grade = '20' at line 1Source Error:
Line 192: con.Open();
Line 193:
Line 194: int ret = cmd.ExecuteNonQuery();
Line 195:
Line 196: con.Close();
Source File: f:\Project\Projects\school\product\AddAchieve.aspx.cs Line: 194 Stack Trace:
[MySqlException: You have an error in your SQL syntax near 'Set honor_name = 'dsb125' ,honor_date = '2005-04-26 00:00:00' ,honor_grade = '20' at line 1]
MySql.Data.MySqlClient.PacketReader.CheckForError() +91
MySql.Data.MySqlClient.PacketReader.ReadHeader() +229
MySql.Data.MySqlClient.PacketReader.OpenPacket() +119
MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) +17
MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst) +71
MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume) +123
MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader) +319
MySql.Data.MySqlClient.MySqlCommand.Consume() +11
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +98
AddAchieve.btnSave_Click(Object sender, ImageClickEventArgs e) in f:\Project\Projects\school\product\AddAchieve.aspx.cs:194
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +105
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +90
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
Server Error in '/school' Application.
--------------------------------------------------------------------------------You have an error in your SQL syntax near 'Set honor_name = 'dsb125' ,honor_date = '2005-04-26 00:00:00' ,honor_grade = '20' at line 1
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax near 'Set honor_name = 'dsb125' ,honor_date = '2005-04-26 00:00:00' ,honor_grade = '20' at line 1Source Error:
Line 192: con.Open();
Line 193:
Line 194: int ret = cmd.ExecuteNonQuery();
Line 195:
Line 196: con.Close();
Source File: f:\Project\Projects\school\product\AddAchieve.aspx.cs Line: 194 Stack Trace:
[MySqlException: You have an error in your SQL syntax near 'Set honor_name = 'dsb125' ,honor_date = '2005-04-26 00:00:00' ,honor_grade = '20' at line 1]
MySql.Data.MySqlClient.PacketReader.CheckForError() +91
MySql.Data.MySqlClient.PacketReader.ReadHeader() +229
MySql.Data.MySqlClient.PacketReader.OpenPacket() +119
MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) +17
MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst) +71
MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume) +123
MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader) +319
MySql.Data.MySqlClient.MySqlCommand.Consume() +11
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +98
AddAchieve.btnSave_Click(Object sender, ImageClickEventArgs e) in f:\Project\Projects\school\product\AddAchieve.aspx.cs:194
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +105
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +90
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
解决方案 »
- comboBox的模糊查询
- 窗口间切换问题
- C#的环境变量
- 如何在一个导出的文件中,再追加导入其他的文件
- 水晶报表出现提示-The type initializer for "CrystalDecisions.CrystalReports.Engine.ReportDocument" threw an exception, 如何解决?
- 高手请进,按钮无效,急?
- 点击lable,然后panel显示
- 各位大哥,关于DATAGRID绑定的问题
- c#输入的小问题
- 映射htm到aspnet_isapi.dll后,正常的htm访问出错!
- 在线等!刚刚开始学C#,遇到一个问题请各位大虾帮忙看看
- 关于DBGRID绑定复选框后,对记录的操作,有点困难?求教!!!
MySqlConnection con = new MySqlConnection(ConfigurationManager.AppSettings["connectString"]);
MySqlCommand cmd;
string strInsert = "Insert Ignore Into product_achieve Values Set ";
string strUpdate = "Update product_achieve Set ";
//公用字符串
string strCommon = "honor_name = ?honor_name ";
strCommon += ",honor_date = ?honor_date ";
strCommon += ",honor_grade = ?honor_grade ";
strCommon += ",honor_sort = ?honor_sort ";
if (txtHonorUnit.Text != "")
{
strCommon += ",honor_unit = ?honor_unit ";
}
if (txtHonorSN.Text != "")
{
strCommon += ",honor_sn = ?honor_sn ";
}//增加记录
if (isAdd)
{
strInsert += strCommon;
strInsert += ",product_id = ?product_id ";
//获取学校的ID
GlobalServer s = new GlobalServer();
Person user = s.CurrentUser;
string univ_id = user.CollegeID;
strInsert += ",univ_id = ?univ_id"; cmd = new MySqlCommand(strInsert,con);
cmd.Parameters.Add("?product_id",int.Parse(dropProductName.SelectedValue));
cmd.Parameters.Add("?univ_id", univ_id);
}
else
{
//更新记录
strUpdate += strCommon;
strUpdate += "Where achieve_id = ?achieve_id";
cmd = new MySqlCommand(strUpdate,con);
cmd.Parameters.Add("?achieve_id",achieve_id);
}
//添加公有的变量
cmd.Parameters.Add("?honor_name",txtHonorName.Text);
cmd.Parameters.Add("?honor_date",DateTime.Parse(txtHonorDate.Text));
cmd.Parameters.Add("?honor_grade",dropHonorGrade.SelectedValue);
cmd.Parameters.Add("?honor_sort",dropHonorSort.SelectedValue);
if(txtHonorUnit.Text != "")
{
cmd.Parameters.Add("?honor_unit",txtHonorUnit.Text);
}if(txtHonorSN.Text != "")
{
cmd.Parameters.Add("?honor_sn",txtHonorSN.Text);
}con.Open();int ret = cmd.ExecuteNonQuery();con.Close();if(ret > 0)
{
lblMessage.Text = "你已经成功操作" + ret.ToString() + "条记录!"; isAdd = true;
achieve_id = -1;
Response.Redirect("addachieve.aspx");
}
==>
cmd.Parameters.Add("?honor_grade",Convert.ToInt32(dropHonorGrade.SelectedValue));
用Insert table(...) values(...)