我看过一个Access的历程,直接给一个绑定到数据库的IMAGE控件设置pirture属性,就可以了
我想Sql也应该一样,应该由数据控件办理了吧
我想Sql也应该一样,应该由数据控件办理了吧
解决方案 »
- VB如何调用des解密图片并绑定到imagelist
- 怎样通过程序设置或添加文件夹的安全访问用户(Windows2000或者windowsXP)?
- vb读取ini的相关问题
- qq被盗,怎么办??
- 关于加密狗的问题。
- Help me!
- 几个ado和dao的新手问题
- 各位大蝦,如何用vb代碼建立sql數據庫???
- 娉婷:怎样使用VB的向导?
- 解决了这个问题的网友请进来领分,"哪位大哥大姐有用VB做的WINSOCK API的原代码给兄弟学习学习!!!!!!"
- 我的VB水平很一般 现在就要找工作了 现在很多公司都VB+SQL SREVR 但我只会VB+ACCESS 开发小型的数据库 我现在应该怎么办?
- 如何将一条记录向前移动几位?
图片文件操作的!
我又一个组件可以实现存入数据库(ADO)!
读取当然很简单了!
用steam!
Const BLOCKSIZE = 4096 '每次读写块的大小Public rsBinary As New ADODB.Recordset
Public Function AddFile(ByVal FileID As Long)
'Return boolean to decide whether refresh files list
Dim strBin As String * 3000
Dim btyGet() As Byte
Dim lngBlockIndex As Long
Dim lngBlocks As Long
Dim lngLastBlock As Long
Dim lngPosition As Long
Dim lngFileLenth As Long
Dim lngIndex As Long
With frmBinary.CommonDialog1
'.InitDir = App.Path
.Filter = "All image files¦*.bmp;*.ico;*.jpg;*.gif¦Bitmap files¦*.bmp¦Icon files¦*.ico¦All files¦*.*"
.filename = ""
On Error GoTo ErrorHandle
.ShowOpen
On Error GoTo 0
If .filename <> "" Then
Open .filename For Binary As #1
lngFileLenth = LOF(1)
lngPosition = 0
'Get block count for loop
lngBlocks = lngFileLenth / BLOCKSIZE
'Get lngth of last block for the last read
lngLastBlock = lngFileLenth Mod BLOCKSIZE
TypeCode = Right(.filename, 3)
rsBinary.AddNew
rsBinary.Fields("typecode") = TypeCode
For lngBlockIndex = 1 To lngBlocks
ReDim btyGet(BLOCKSIZE)
Get #1, , btyGet()
rsBinary.Fields("content").AppendChunk btyGet()
lngPosition = lngPosition + BLOCKSIZE
Next If lngLastBlock > 0 Then
ReDim btyGet(lngLastBlock)
Get #1, , btyGet()
rsBinary.Fields("content").AppendChunk btyGet()
End If
rsBinary.Fields("id") = FileID
rsBinary.Update
rsBinary.UpdateBatch
Close #1
AddFile = True
MsgBox "Save finished", vbInformation
Else
AddFile = False
End If
End With
Exit Function
ErrorHandle:
AddFile = False
End Function'从数据库取文件出来
Public Sub SaveFile(ByVal FileID As Long)
Dim lngBlockCount As Long
Dim lngLastBlock As Long
Dim lngI As Long
Dim btyBlock() As Byte
Dim lngResult As Long
If rsBinary.EOF And rsBinary.BOF Then Exit Sub
rsBinary.Requery
rsBinary.MoveFirst
rsBinary.Find " id=" & FileID
If Not rsBinary.EOF Then
With frmBinary.CommonDialog1
.filename = "TempSave" & "." & rsBinary.Fields("typecode")
'.InitDir = App.Path
'If user cancel save the goto handle
On Error GoTo ErrorHandle
.ShowSave
If .filename <> "" Then
lngBlockCount = rsBinary.Fields("content").ActualSize \ BLOCKSIZE
lngLastBlock = rsBinary.Fields("content").ActualSize Mod BLOCKSIZE
If Dir(.filename) <> "" Then
If MsgBox("File " & .filename & " is exist,overwrite?", vbYesNo + vbQuestion) = vbYes Then
Kill .filename
Else
Exit Sub
End If
Else
End If
Open .filename For Binary As #1
ReDim btyBinary(BLOCKSIZE)
For lngI = 1 To lngBlockCount
btyBlock() = rsBinary.Fields("content").GetChunk(BLOCKSIZE)
Put #1, , btyBlock
Next
If lngLastBlock <> 0 Then
ReDim btyBlock(lngLastBlock)
btyBlock() = rsBinary.Fields("content").GetChunk(lngLastBlock)
Put #1, , btyBlock
End If
Close #1
MsgBox .filename & " is saved", vbInformation
Else
End If
End With
End If
Exit Sub
ErrorHandle:
End Sub