就下面几句代码,一运行就出错,提示“关闭对象时,不允许操作”,我并没有关闭对象啊,在这之前也没有其它的代码,对于这个错误我感到很奇怪,哪位帮帮忙看看是怎么回事啊,先谢谢了!
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;Persist Security Info=False"
Adodc1.RecordSource = "update member set m_money='1' where m_name='张三'"
Adodc1.Refresh

解决方案 »

  1.   

    你的对象还没打开~
    adodc1.Open
      

  2.   

    Private Sub Command1_Click()
    Adodc1.RecordSource = "select * from member "Adodc1.Refresh
    End SubPrivate Sub Form_Load()
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;Persist Security Info=False"
    Adodc1.RecordSource = "update member set m_money='1' where m_name='张三'"
    End Sub
      

  3.   

    Adodc1.RecordSource = "select * from member "这句重要一般不推荐这种写法
      

  4.   

    用的Adobe控件,楼上的都不行,我要的就是更新一个数据库记录,整个就三行代码,怎么就不行呢?
    请各位给出完整的代码,我觉得就是连接数据,然后写sql语句,最后执行,就这三步啊,怎么在我的上面就不能运行?其它的还要做什么??
      

  5.   


    这是测试过的
    你修改数据,不能做记录集,reflesh会出问题
    所以给你加了
    Adodc1.RecordSource = "select * from member "其实这种处理方式不好
      

  6.   

    楼上,你的我测试过了数据根本没有更新,下面是我按照你的这个做的工程文件,你看看
    http://www.symental.com/sfw?f=testdb另外我用select语句可以达到这个效果,代码如下:
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;Persist Security Info=False"
    Adodc1.RecordSource = "select * from member where m_name='张三'"
    Adodc1.Refresh
    Adodc1.Recordset("m_money") = "qqqqqqqq"
    Adodc1.Recordset.Update
    但是我想知道update语句在Adobe中到底该怎样用,我觉得update才是一步到位的,它不是sql的标准语句吗?
      

  7.   


    Private Sub s_save()
        Dim con As New Connection
        Dim strS As String
        
        con.CursorLocation = adUseClient
        con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;Persist Security Info=False"
        
        strS = "update member set m_money='1' where m_name='张三'"
        
        con.BeginTrans
        con.Execute strS, con, adOpenStatic, adLockOptimistic
        con.CommitTrans
        
        con.Close
        Set con = Nothing
        
        Exit Sub
    ERRS:
        MsgBox Err.Number & ", " & Err.Description, vbOKOnly + vbExclamation, "SAVE"
        con.RollbackTrans
        
        con.Close
        Set con = Nothing
        
    End Sub
      

  8.   

    楼上的是adodb的方法,我知道的,我只是想知道用adodc如何做。