简易自制鸡喂料槽图片:asp.net-操作必须使用一个可更新的查询?

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 01:48:43
在vs2003种建立了一个asp.net web应用程序

放了三个textbox,一个dropdownlist,一个button

button------------

private void Button1_Click(object sender, System.EventArgs e)
{
OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\wwwroot\\WebApplication1\\wwwlink.mdb");
String strsql="insert into link(sitename,URL,intro,grade,submit_date) values('"+setname.Text+"','"+url.Text+"','"+intro.Text+"',"+Convert.ToInt16(grade.SelectedItem.Text)+",#"+System.DateTime.Now+"#)";
OleDbCommand cmd=new OleDbCommand (strsql,conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}

开头引用了using System.Data.OleDb;

运行之后错误:

Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------

操作必须使用一个可更新的查询。
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.Data.OleDb.OleDbException: 操作必须使用一个可更新的查询。

Source Error:

Line 58: OleDbCommand cmd=new OleDbCommand (strsql,conn);
Line 59: conn.Open();
Line 60: cmd.ExecuteNonQuery();
Line 61: conn.Close();
Line 62: }

这个代码在其他机器上面运行通过,有一部分出现这个错误

运行其他asp.net都是正确的

高手指点一下吧,我是弄不明白了~~~~~

先谢谢了~~~~~!

Access数据库所在目录没有写权限,开放相关权限就可以解决问题

如果connection设置正确的话,那么将会是细节上的错误
比如int32可以不可以, int i=cmd.ExecuteNonQuery();看看i=多少, 其他的detail 楼主多调试一下拉。