Set Adotemp1_Cal = New ADODB.Recordset
    Set Conntemp1_Cal = New ADODB.Connection
    Set Cmdtemp1 = New ADODB.Command
    Conntemp1_Cal.Open cntstrtemp
    Cmdtemp1.ActiveConnection = Conntemp1_Cal
    Adotemp1_Cal.CursorLocation = adUseClient
    Adotemp1_Cal.CursorType = adOpenkeyset
    Adotemp1_Cal.LockType = adLockOptimistic
    Cmdtemp1.CommandText = "delete from 营业明细"
    Set Adotemp1_Cal = Cmdtemp1.Execute
    .........(又往表中写入10条数据)
    Cmdtemp1.commandtext="select * from 营业明细"
    此时Adotemp1_cal.Recordcount竟然是-1
    请问怎么回事???

解决方案 »

  1.   

    你的连接使用的是服务器端游标在打开连接之前,多写一句
    Conntemp1_Cal.CursorLocation = adUserClient
    就OK了
      

  2.   

    Set Adotemp1_Cal = Cmdtemp1.Execute
    之后再看看Conntemp1_Cal.CursorLocation的值试试
      

  3.   

    if Adotemp1_cal.eof  then
        msgbox "没有记录"
    else
        Adotemp1_cal.movenext
        msgbox "记录数量=" & Adotemp1_cal.recordcount
    endif
     
      

  4.   

    Adotemp1_Cal.CursorType = adopenstatic
        Adotemp1_Cal.LockType = adlockreadonly
      

  5.   

    另:
    我是用insert into来添加的记录。
      

  6.   

    改成Adotemp1_Cal.CursorType = adOpenKeyset
      

  7.   

    直接用adodc控件不是省很多事吗?
      

  8.   

    Set Adotemp1_Cal = New ADODB.Recordset
        Set Conntemp1_Cal = New ADODB.Connection
        
        Conntemp1_Cal.Open cntstrtemp    Conntemp1_Cal.BeginTrans    Conntemp1_Cal.Execute "delete from 营业明细"    .........(又往表中写入10条数据)    Conntemp1_Cal.CommitTrans    Adotemp1_Cal.CursorLocation = adUseClient
        Adotemp1_Cal.CursorType = adOpenKeyset
        Adotemp1_Cal.LockType = adLockOptimistic
        
        Adotemp1_Cal.Open "select *  from 营业明细", Conntemp1_Cal
      

  9.   

    用下面这句解决问题
    Conntemp1_Cal.CursorLocation = adUserClient