db.BeginTrans();
try
{
string strsql1="insert into DBFMapPath (mappath,strtime) values (?,?)";
string[] strParams=new string[2]{"@mappath","@strtime"};
object[] objValues=new object[2]{""+filepath+"",""+DateTime.Now.ToShortDateString().ToString()+""};
Response.Write(strsql1);
db.exeSql(strsql1,strParams,objValues);
db.CommitTrans();
}
catch(Exception ex)
{
db.RollbackTrans();
Response.Write(ex.ToString());
}
db.Close();
public override void exeSql(string strSql, string[] strParams, object[] objValues)
{
OleDbCommand Cmd=new OleDbCommand();
Cmd.Connection=this.conn;
if(inTransaction)
Cmd.Transaction=trans;
if((strParams!=null)&&(strParams.Length!=objValues.Length))
throw new Exception("查询参数和值不对应!");
Cmd.CommandText=strSql;
if(strParams!=null)
{
for(int i=0;i<strParams.Length;i++)
{
Cmd.Parameters.Add(strParams[i],objValues[i]);
}
}
Cmd.ExecuteNonQuery();
}错误为System.Data.OleDb.OleDbException: 操作必须使用一个可更新的查询。

解决方案 »

  1.   

    你的access数据库为只读了,去掉只读属性,如果要权限,你在给它一个可读写权限就可以。
      

  2.   

    string strsql1="insert into DBFMapPath (mappath,strtime) values (@mappath,@strtime)";//参考一下这个
    Sub ExeTransaction (Byval Sqlstrlist as string())
                          Dim  Conn As String = 
                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Tax.mdb" 
                          Dim trans as OledbTransaction=Nothing
                          Try
                                If conn.State=connectionstate.closed then
                Conn.open()
                                    End if
                Dim cmd as oledbCommand=new oledbcommand()
                cmd.connection=conn
                cmd.commandtype=commandtype.text
                trans=conn.BeginTransaction()
                cmd.Transaction=trans
                dim I as integer
                 for I=0 to Sqlstrlist.GetupperBound(0)
                       cmd.commandText= Sqlstrlist(i) ‘取得参数(数组)中的值
                       cmd.ExecuteNonQuery()
                Next
                Trans.commit()
                Catch ex as oledbexception
                     Trans.Rollback()
                Fanlly
                     Conn.close()
                End try
                      End sub
      

  3.   

    应该是数据库的权限问题,在数据库所在文件夹,右键->属性->安全,添加用户ASPNET,并赋予其“完全控制”的权限。
      

  4.   

    右键->属性->安全,添加用户ASPNET,并赋予其“完全控制”的权限。
    或者everyone完全控制
      

  5.   

    谢谢大家,郁闷了我一个晚上,终于解决了,原来这么简单我的解决办法是右键->属性->安全,然后把USER用户的权限设成完全控制,这样就可以了我也加过ASPNET用户,也设成了完全控制,但是好象不可以,EVERYONE没有试过