string strConnection="Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
strConnection+=Server.MapPath("cnetdata\\cnet.mdb");
OleDbConnection mdiconn=new OleDbConnection(strConnection);
mdiconn.Open();
OleDbCommand mdicommand = new OleDbCommand("Update pwd Set name='"+newnamebox.Text+"',pawd='"+newpwdbox.Text+"' where name='"+oldnamebox.Text+"'and pawd='"+oldpwdbox.Text+"'",mdiconn);
if (mdicommand.ExecuteNonQuery()>0)
{
Page.RegisterStartupScript("Alert","<script language=javascript>alert('密码更改成功,请返回!');</script>");
oldnamebox.Text="";
newnamebox.Text="";
}
else
Page.RegisterStartupScript("Alert","<script language=javascript>alert('密码更改iasd成功,请返回!');</script>");结果为“/WebApplication2”应用程序中的服务器错误。
--------------------------------------------------------------------------------操作必须使用一个可更新的查询。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 操作必须使用一个可更新的查询。源错误:
行 72: mdiconn.Open();
行 73: OleDbCommand mdicommand = new OleDbCommand("Update pwd Set name='"+newnamebox.Text+"',pawd='"+newpwdbox.Text+"' where name='"+oldnamebox.Text+"'and pawd='"+oldpwdbox.Text+"'",mdiconn);
行 74: if (mdicommand.ExecuteNonQuery()>0)
行 75: {
行 76: Page.RegisterStartupScript("Alert","<script language=javascript>alert('密码更改成功,请返回!');</script>");
源文件: D:\Inetpub\wwwroot\WebApplication2\modipassword.aspx.cs 行: 74 堆栈跟踪:
[OleDbException (0x80004005): 操作必须使用一个可更新的查询。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
WebApplication2.modipassword.okbt_Click(Object sender, EventArgs e) in D:\Inetpub\wwwroot\WebApplication2\modipassword.aspx.cs:74
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 这个我在家里的机子上运行正常,可是一到公司的机子上就成这样了,请请各位帮忙解决一下!
mdiconn.Close();
strConnection+=Server.MapPath("cnetdata\\cnet.mdb");
OleDbConnection mdiconn=new OleDbConnection(strConnection);
mdiconn.Open();
OleDbCommand mdicommand = new OleDbCommand("Update pwd Set name='"+newnamebox.Text+"',pawd='"+newpwdbox.Text+"' where name='"+oldnamebox.Text+"'and pawd='"+oldpwdbox.Text+"'",mdiconn);
if (mdicommand.ExecuteNonQuery()>0)
{
Page.RegisterStartupScript("Alert","<script language=javascript>alert('密码更改成功,请返回!');</script>");
oldnamebox.Text="";
newnamebox.Text="";
}
else
Page.RegisterStartupScript("Alert","<script language=javascript>alert('密码更改iasd成功,请返回!');</script>");结果为“/WebApplication2”应用程序中的服务器错误。
--------------------------------------------------------------------------------操作必须使用一个可更新的查询。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 操作必须使用一个可更新的查询。源错误:
行 72: mdiconn.Open();
行 73: OleDbCommand mdicommand = new OleDbCommand("Update pwd Set name='"+newnamebox.Text+"',pawd='"+newpwdbox.Text+"' where name='"+oldnamebox.Text+"'and pawd='"+oldpwdbox.Text+"'",mdiconn);
行 74: if (mdicommand.ExecuteNonQuery()>0)
行 75: {
行 76: Page.RegisterStartupScript("Alert","<script language=javascript>alert('密码更改成功,请返回!');</script>");
源文件: D:\Inetpub\wwwroot\WebApplication2\modipassword.aspx.cs 行: 74 堆栈跟踪:
[OleDbException (0x80004005): 操作必须使用一个可更新的查询。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
WebApplication2.modipassword.okbt_Click(Object sender, EventArgs e) in D:\Inetpub\wwwroot\WebApplication2\modipassword.aspx.cs:74
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 这个我在家里的机子上运行正常,可是一到公司的机子上就成这样了,请请各位帮忙解决一下!
mdiconn.Close();
公网访问jiu就要everyone权限,方法同 hackate(兰花开香入梦境,独思佳人亦飘然!!) ( )给点建议,楼主应该先搜索一样是否论坛已有类似的问题,特别像这种常见到问题,
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
strConnection+=Server.MapPath("cnetdata\\cnet.mdb");
OleDbConnection schoolconn=new OleDbConnection(strConnection);
schoolconn.Open();
OleDbCommand mycommand = new OleDbCommand("Update scinfo Set scname='"+scnamebox.Text+"',sccode='"+sccodebox.Text+"'" ,schoolconn);
if (mycommand.ExecuteNonQuery()>0)
{
Page.RegisterStartupScript("Alert","<script language=javascript>alert('数据更新成功,请返回!');</script>");
backbt.Text="返回"; }
else
Page.RegisterStartupScript("Alert","<script language=javascript>alert('数据更新失败,请重新填写或返回!');</script>");
schoolconn.Close();
>
在另一个更新中,我是这么写的如果更新所影响的行数大于0说明是被更新了,可是我到数据库里看却发现还是原来的数据,一点都没变又是怎么回事呢?