OleDbConnection conn=new OleDbConnection(connStr);
OleDbCommand cmd = new OleDbCommand(strSql,conn);
conn.Open();//没问题
cmd.ExecuteNonQuery();//出现异常conn连接没有问题, 我把strSql考到access里面运行也没问题, 很奇怪为什么上面那句会出现异常
OleDbCommand cmd = new OleDbCommand(strSql,conn);
conn.Open();//没问题
cmd.ExecuteNonQuery();//出现异常conn连接没有问题, 我把strSql考到access里面运行也没问题, 很奇怪为什么上面那句会出现异常
解决方案 »
- 。net输出数据的格式貌似不灵活啊
- 求问 c# 函数 有没有一种,能把小数直接归为整的函数,如将1.1转了2, 5.002转为6,的这种函数
- 用HttpRequest提交携程的查询表单不返回正确的结果
- 我想对于大家这是简单的问题:关于取整形数据~~
- 关于存储过程
- 新手,向各位高手请教我的想法如何实现
- 对于.net 要不要继续坚持下去,对于程序员要不要坚持下去.来个指引路的老师
- 这都要出错,崩溃了,help me
- RegisterStartupScript到底怎么用,什么时候用?查了帮助,没太看懂,哪位给通俗点讲一下,最好有例子
- 模板列中的正则表达式!
- 请问:如何在单击了不同的button按钮后在label处显示不同的用户控件
- 在程序中使用了Internet Explorer WebControls,该如何设置?
{
conn.Open();//没问题
cmd.ExecuteNonQuery();//出现异常
}
catch(Exception ex)
{
Response.Write(ex.ToString());
==================================
你的sql没有参数?你对数据库文件是否有访问得权限?
}
比如说id,count,之类的,有的话在字段名称两边加上[]
例如
select [ID] ,[NAME],[COUNT] FROM User WHERE [ID] = 2
strSql = "insert into users(userID,userPwd,regDate) values('hunter','hunter','1:59 PM')";
OleDbConnection conn=new OleDbConnection(connStr);
OleDbCommand cmd=new OleDbCommand(strSql,conn);
try
{
conn.Open ();
cmd.ExecuteNonQuery ();
Response.Write ("<script language='javascript'> alert('注册成功') </script>");
Session["userID"]=this.txtRegUserName.Text ;
Response.Redirect ("userCenter.aspx");
}
catch(System.Exception ex)
{
throw new Exception (ex.Message );
}
finally
{
conn.Close ();
}
数据库文件是我自己建的, 所以肯定有权限啊,
放到ACCESS看能不能执行
Operation must use an updateable query.
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: System.Exception: Operation must use an updateable query.Source Error:
Line 86: catch(System.Exception ex)
Line 87: {
Line 88: throw new Exception(ex.Message );
Line 89: }
Line 90: finally
Source File: c:\inetpub\wwwroot\yiudata\register.aspx.cs Line: 88 Stack Trace:
[Exception: Operation must use an updateable query.]
yiudata.register.btnReg_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\yiudata\register.aspx.cs:88
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +232
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +5
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +31
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5157
insert into users(userID,userPwd,regDate) values('hunter','hunter','1:59 PM')"
这句可以执行
{
conn.Open ();
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery ();
…………