没用过dao,不过没看到你的打开方式,恐怕你的打开方式是只读的吧,

解决方案 »

  1.   

    我通常打开recordset的作法:
    Dim rstEmp As New ADODB.Recordset
    rstEmp.Open "select ... from ... where ...", AdoConn, adOpenStatic, adLockReadOnly
    下边你就可以addnew 和update 不过addnew的时候我通常是
    AdoConn.execute "insert into table ....."
      

  2.   

    确实是设成只读了。
    但是,addnew后面的update又出错了。
      

  3.   

    如果你是用Jet workspace 打开的数据库,就不要用type 参数,例如dbOpenDynaset等等
      

  4.   

    是ODBC 的话,加上dbPessimistic
      

  5.   

    Set rstNew = dbs.OpenRecordset("select ID,频道名称 from 频道 where ID < 0")rstNew.AddNew
    rstNew.Fields("ID").Value = j
    rstNew.Fields("频道名称").Value = rst.Fields("频道名称").Value
    rstNew.Update
    ~~~~~~~~~~~~~出错
      

  6.   

    Set dbs = OpenDatabase("xxx", False, False)   'Open Database with Shared ,Writable mode
      

  7.   

    实际上rstNew是一个临时的recordset,只在内存中存在。
      

  8.   

    可能和你用了查询语句有关,试试将sql查询语句去掉。
    Set  rstNew  =  dbs.OpenRecordset("表格",  dbOpenRecordset)
      

  9.   

    对不起,最后一句打错了。
    应该写成  Set rstNew =dbs.OpenrecordSet("表格",dbOpenTable)
      

  10.   

    多谢指教。
    这样会不会修改数据库的内容?
    我只是想临时生成一个recordset供程序使用。
      

  11.   

    ADO中创建临时表
    ---------------
    DIM RS AS ADO.RECORDSET
    SET RS=NEW ADO.RECORDSET
    RS.FIELDS.APPEND "ID",ADINTERGER,,ADFLDKEYCOLUMN
    RS.FIELDS.APPEND "DESCRIPTION",ADVARCHAR,40
    RS.OPEN LOCKTYPE:=ADLOCKBATCHOPTIMISTIC
    RS.ADDNEW
    RS.FIELDS(ID).VALUE=1
    RS.FIELD(DESCRIPTION).VALUE="FIRST RECORD"
    RS.UPDATE也可以用 SQL 语句:
    -----------------
    strSql = " Create Table #tmpTest(PartCode varchar(30),PartRule varchar(300))"
    Con.Execute strSql
    strSql = " INSERT INTO #tmpTest Select PartCode ,PartRule From tblstock"
    Con.Execute strSql
      

  12.   

    sonicdater(发呆呆) addnew时出错。
      

  13.   

    dim adocon as adodb.connection
    dim adores as adodb.recordset
    dim strsql as string
    set adocon = new adodb.connection
    adocon.open datapath
    strsql = "select * from tblname"
    set adores = new adodb.recordset
    set adores = adocon.excute(strsql)
    adores.close
    set adores = nothing
    adocon.close
      

  14.   

    Dim  rstNew  As  Recordset 这一句应改为
    dim rstnew as new recordset.
      

  15.   

    原来是忘了这一句:
    RS.OPEN LOCKTYPE:=ADLOCKBATCHOPTIMISTIC给分!
      

  16.   

    原来是忘了这一句:
    RS.OPEN LOCKTYPE:=ADLOCKBATCHOPTIMISTIC给分!
      

  17.   

    原来是忘了这一句:
    RS.OPEN LOCKTYPE:=ADLOCKBATCHOPTIMISTIC给分!