我想请问一下,VB中如何通过对话框选中的图片保存入数据库。能否给个例子!

解决方案 »

  1.   

    Sub SavePicToDb(cn As ADODB.Connection, table1 As String, field1 As String, file1 As String, id1 As String)
            On Error Resume Next
        Dim stm As ADODB.Stream
        Set stm = New ADODB.Stream
        Set rs1 = New ADODB.Recordset
        rs1.Open "select * from " & table1 & " where id = " & id1, cn, adOpenKeyset, adLockOptimistic
        With stm
            .Type = adTypeBinary
            .Open
            .LoadFromFile file1  'DLG.FileName
        End With
        With rs1
             .Fields(field1) = stm.Read
             .Update
        End With
        rs1.Close
        Set rs1 = Nothing
    End Sub