加一个表Picture
ID autonumber
Picture ole object(access)
ID autonumber
Picture ole object(access)
解决方案 »
- 请教lprasdialparams.dwSize设置问题。
- VB调用VC6.0写的DLL,换了台机器就报错,大家帮帮忙
- SetupFactoryF打包问题???
- 字符串转换为变量的问题 "vbKeyA" =>vbKeyA
- 关于调用CryptAcquireContext的问题,请高手解答>>>>>>>>>>>>>>>>>>>.
- 请教如何在程序中修改屏幕分辨率
- 数据库导出的问题
- VSFLEXGRID控件中是否可以添加图标?
- 请请JennyVenus() 接分!
- 如何做一个像“资源管理器中的拷贝画面”那样的东西!!!!!
- 关于多个表合并的问题,很急,最好马上解决。劳驾各位了!
- 怎么实现象资源管理器那样的MDI窗口?
Public Function AddPicture(ByVal sID As String, ByRef abPic() As Byte) As Integer
Dim oRS As New ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT ID,Picture FROM " & gcsTablePicture
With oRS
.Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
.AddNew
.Fields("ID") = sID
.Fields("Picture").AppendChunk abPic
.Update
End With
Set oRS = Nothing
End FunctionPublic Function DeletePicture(ByVal sID As String) As Boolean
Dim sSQL As String
sSQL = "DELETE FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
DeletePicture = ExecuteSQL(sSQL)
End Function
Public Function GetPicture(ByRef sID As String) As Byte()
Dim sSQL As String
Dim oRS As New ADODB.Recordset
Dim abPic() As Byte
Dim lPicSize As Long
sSQL = "SELECT ID,Picture FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
With oRS
.Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
lPicSize = .Fields("Picture").ActualSize - 1
If lPicSize < 0 Then GoTo EndRow
GetPicture = .Fields("Picture").GetChunk(lPicSize)
End With
EndRow:
Set oRS = Nothing
End Function
加一个表Picture
ID autonumber
Picture ole object(access)
^^^^^^^
要显示多幅,连续调用即可
Function showpicture(outtb As String, name As String, number As String, filefield As String) 'As BooleanDim outrs As New ADODB.Recordset
Dim picstream As ADODB.Stream
Dim constr As String
Dim outconn As New ADODB.Connectionoutconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\.mdb;Persist Security Info=False"
outconn.Open
Set picstream = New ADODB.Stream
picstream.Mode = adModeReadWrite
picstream.Type = adTypeBinary
picstream.Open
Set outrs = New ADODB.Recordset
outrs.Source = "select" + " " + filefield + " " + "from" + " " + outtb + " " + " where 姓名=" + "'" + name + "'" + " and 序号=" + numberSet outrs.ActiveConnection = outconnoutrs.LockType = adLockOptimistic
outrs.CursorType = adOpenKeyset
outrs.OpenDim msgstring As StringIf outrs.Fields(filefield).ActualSize <> 0 Then
picstream.Write (outrs.Fields(filefield).Value)
picstream.SaveToFile "c:\aa.tmp", adSaveCreateOverWrite
Picture1.Picture = LoadPicture("c:\aa.tmp")
'******************************************
'Picture1.Picture = LoadPicture(filename)
If Picture1.Picture = 0 Then
Exit Function
End If
Else
'msgstring = filefield + "没有记录"
'MsgBox msgstring, vbOKOnly, "没有记录"
Picfinal.Picture = LoadPicture("")
'showpicture = False
End Ifoutrs.Close
picstream.Close
outconn.CloseEnd Function
Public Function AddPicture(ByVal sID As String, ByRef abPic() As Byte) As Integer
Dim oRS As New ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT ID,Picture FROM " & gcsTablePicture
With oRS
.Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
.AddNew
.Fields("ID") = sID
.Fields("Picture").AppendChunk abPic
.Update
End With
Set oRS = Nothing
End FunctionPublic Function DeletePicture(ByVal sID As String) As Boolean
Dim sSQL As String
sSQL = "DELETE FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
DeletePicture = ExecuteSQL(sSQL)
End Function
Public Function GetPicture(ByRef sID As String) As Byte()
Dim sSQL As String
Dim oRS As New ADODB.Recordset
Dim abPic() As Byte
Dim lPicSize As Long
sSQL = "SELECT ID,Picture FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
With oRS
.Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
lPicSize = .Fields("Picture").ActualSize - 1
If lPicSize < 0 Then GoTo EndRow
GetPicture = .Fields("Picture").GetChunk(lPicSize)
End With
EndRow:
Set oRS = Nothing
End Function