asp.net中遇到的问题

dogaazz 2014-06-15 07:28:12
UPDATE 语句的语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.OleDb.OleDbException: UPDATE 语句的语法错误。

源错误:


行 43: com = new System.Data.OleDb.OleDbCommand(strSql, con);
行 44: con.Open();
行 45: com.ExecuteNonQuery();
行 46: com.Dispose();
行 47: con.Close();


源文件: d:\Archive\Archive\Archive\Archive\WebSite1\pswd1.aspx.cs 行: 45

堆栈跟踪:


[OleDbException (0x80040e14): UPDATE 语句的语法错误。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +99
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +239
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +351
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +88
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +195
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +120
Archive_Archive_Archive_WebSite1_pswd1.Button1_Click(Object sender, EventArgs e) in d:\Archive\Archive\Archive\Archive\WebSite1\pswd1.aspx.cs:45
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +126
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +135
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +39
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +37
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +87
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4178




代码
public partial class Archive_Archive_Archive_WebSite1_pswd1 : System.Web.UI.Page
{
protected System.Data.OleDb.OleDbCommand com;
protected System.Data.OleDb.OleDbDataReader reader;
protected System.Data.OleDb.OleDbConnection con;
protected System.Data.OleDb.OleDbDataAdapter da;
protected System.Data.DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("st.mdb") + ";User Id=admin;Password=;";
con = new OleDbConnection(strcon);
string id, strSql;
id = Session["admin"].ToString();

}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != TextBox2.Text)
{
Response.Write("<script>alert('两次输入不同,请重新输入!');</script>");
TextBox1.Text = "";
TextBox2.Text = "";
}
else
{
string id, strSql;
id = Session["admin"].ToString();
strSql = "update student set password='123456'where number='31101339'"; //+ TextBox1.Text + "'where number='" + id + "'";

com = new System.Data.OleDb.OleDbCommand(strSql, con);
con.Open();
com.ExecuteNonQuery();
com.Dispose();
con.Close();
}
}
提示我UPDATA语句错误但问题是我把语句在数据库执行过显示是对的
...全文
251 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
桃子先生 2014-06-16
  • 打赏
  • 举报
回复
引用 1 楼 guwei4037 的回复:
strSql = "update student set password='123456' where number='31101339'"; --where前面加个空格,另外number字段是字符串?
+1
游侠风行者 2014-06-16
  • 打赏
  • 举报
回复
引用 5 楼 u010703853 的回复:
[quote=引用 3 楼 qin7wy5lp 的回复:] [quote=引用 1 楼 guwei4037 的回复:] strSql = "update student set password='123456' where number='31101339'"; --where前面加个空格,另外number字段是字符串?
+1[/quote] +1[/quote] +1
  • 打赏
  • 举报
回复
引用 3 楼 qin7wy5lp 的回复:
[quote=引用 1 楼 guwei4037 的回复:] strSql = "update student set password='123456' where number='31101339'"; --where前面加个空格,另外number字段是字符串?
+1[/quote] +1
smthgdin_020 2014-06-16
  • 打赏
  • 举报
回复
引用 1 楼 guwei4037 的回复:
strSql = "update student set password='123456' where number='31101339'"; --where前面加个空格,另外number字段是字符串?
+1
EdsionWang 2014-06-15
  • 打赏
  • 举报
回复
同意楼上。从贴出来的update代码来看,只有这点问题
全栈极简 2014-06-15
  • 打赏
  • 举报
回复
strSql = "update student set password='123456' where number='31101339'"; --where前面加个空格,另外number字段是字符串?

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧