Recordset 对象必须支持更新 update 方法 不行就用 UpdateBatch 方法

解决方案 »

  1.   

    Recordset 对象必须支持更新 update 方法 不行就用 UpdateBatch 方法
      

  2.   

    这位仁兄!用了UpdateBatch方法还是无效呀?
      

  3.   

    Recordset 对象是否支持更新?
      

  4.   

    就这么一段程序:
    Public Sub save_Doc()On Error GoTo ErrHandleDim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim bit() As Byte
    Dim varPath As String '文档的路径
    Dim sSql As String
    Dim lngFileName As Integer    lngFileName = FreeFile()
        
        varPath = App.Path & "\Hg_Jckfxwz\" & txtWzxh.Text & ".doc"
        cnn.Open ConnStr    sSql = "SELECT * FROM " & tabName & " WHERE Wzxh = " & txtWzxh.Text
                                 '选出要增加或修改文档的记录    rst.Open sSql, cnn, adOpenKeyset, adLockOptimistic    If Not (rst.EOF And rst.BOF) Then
           If varPath = "" Then
            '    然后将字节数组的内容写入数据库即可
                rst.Fields("Wznr1") = ""
                rst.Update
           Else
                Open varPath For Binary As lngFileName
                ReDim bit(LOF(lngFileName)) As Byte
                Get lngFileName, 1, bit()
             '    然后将字节数组的内容写入数据库即可            rst.Fields("Wznr1").AppendChunk (bit())
                rst.Update
                MsgBox "Save to database success.", vbOKOnly + vbInformation, "保存成功"
                Close lngFileName
           End If
           rst.Close
           cnn.Close
        End If
        Exit Sub
    ErrHandle:
        MsgBox "错误(" & Err.Number & ") : " & Err.Description & vbCrLf & "Save to database failure!", vbOKOnly + vbCritical, "保存失败"
        If rst.State = adStateOpen Or rst.State = adStateOpen + adStateExecuting Or rst.State = adStateOpen + adStateFetching Then
            rst.Close
        End If
        If cnn.State = adStateOpen Then
            cnn.Close
        End If
        Close lngFileName
        Exit Sub
    End Sub执行完后,数据库中却没有值。什么原因呢?