存:
Public Sub save_picture()
Dim cnn As New ADODB.Connection, rst As New ADODB.Recordset
Dim bit() As Byte
dim varPath as string '图片的路径 cnn.open "连接数据库的字符串"
sSql = "SELECT * FROM 表 WHERE 关键字='" & 关键值 & "'"
'选出要增加或修改图片记录的记录
rst.Open sSql, cnn, adOpenKeyset, adLockOptimistic
If Not (rst.EOF And rst.BOF) Then
If VarPath = "" Then
' 然后将字节数组的内容写入数据库即可
rst.Fields("INFO_PICT") = ""
rst.UPDATE
Else
Open VarPath For Binary As #1
ReDim bit(LOF(1)) As Byte
Get 1, 1, bit
Close 1
' 然后将字节数组的内容写入数据库即可
rst.Fields("INFO_PICT").AppendChunk bit
rst.UPDATE
End If
End If
end sub 取:
Public Sub show_picture()
Dim REC As Recordset
Dim sSql As String
Dim I As Integer
Set REC = New Recordset
Dim bit1() As Byte
Dim sa As String
sSql = "SELECT * FROM 表 WHERE 关键字 ='" & 关键值 & "'"
REC.Open sSql, Conn, adOpenStatic, adLockOptimistic, adCmdText
If REC.EOF Or REC.BOF Then
Exit Sub
Else
REC.Movefirst
While Not REC.BOF
Picture1.Picture = Nothing
If REC("INFO_PICT").ActualSize > 0 Then
bit1 = REC.Fields("图片").GetChunk(REC("图片").ActualSize)
'然后将字节数组的内容拼装成文件即可
Open "c:\1.bmp" For Binary As #1
Put 1, 1, bit1
Close 1
Picture1.Picture = LoadPicture"c:\1.bmp")
End If
REC.Movenext
Wend
End If
rec.close
Set REC = Nothing
Exit Sub
Err:
MsgBox "读取图片出错!", OKOnly, "系统提示"
End Sub
Public Sub save_picture()
Dim cnn As New ADODB.Connection, rst As New ADODB.Recordset
Dim bit() As Byte
dim varPath as string '图片的路径 cnn.open "连接数据库的字符串"
sSql = "SELECT * FROM 表 WHERE 关键字='" & 关键值 & "'"
'选出要增加或修改图片记录的记录
rst.Open sSql, cnn, adOpenKeyset, adLockOptimistic
If Not (rst.EOF And rst.BOF) Then
If VarPath = "" Then
' 然后将字节数组的内容写入数据库即可
rst.Fields("INFO_PICT") = ""
rst.UPDATE
Else
Open VarPath For Binary As #1
ReDim bit(LOF(1)) As Byte
Get 1, 1, bit
Close 1
' 然后将字节数组的内容写入数据库即可
rst.Fields("INFO_PICT").AppendChunk bit
rst.UPDATE
End If
End If
end sub 取:
Public Sub show_picture()
Dim REC As Recordset
Dim sSql As String
Dim I As Integer
Set REC = New Recordset
Dim bit1() As Byte
Dim sa As String
sSql = "SELECT * FROM 表 WHERE 关键字 ='" & 关键值 & "'"
REC.Open sSql, Conn, adOpenStatic, adLockOptimistic, adCmdText
If REC.EOF Or REC.BOF Then
Exit Sub
Else
REC.Movefirst
While Not REC.BOF
Picture1.Picture = Nothing
If REC("INFO_PICT").ActualSize > 0 Then
bit1 = REC.Fields("图片").GetChunk(REC("图片").ActualSize)
'然后将字节数组的内容拼装成文件即可
Open "c:\1.bmp" For Binary As #1
Put 1, 1, bit1
Close 1
Picture1.Picture = LoadPicture"c:\1.bmp")
End If
REC.Movenext
Wend
End If
rec.close
Set REC = Nothing
Exit Sub
Err:
MsgBox "读取图片出错!", OKOnly, "系统提示"
End Sub
sp_textcopy @srvname = 'ServerName',
@login = 'Login',
@password = 'Password',
@dbname = 'pubs',
@tbname = 'pub_info',
@colname = 'logo',
@filename = 'c:\picture.bmp',
@whereclause = " WHERE pub_id='0736' ",
@direction = 'I'