'保存
Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset
Dim InterID As String
Dim strData As String
Dim fileNo As Integer
Dim LenF As Long
Dim BMPData() As Byte
Dim mFileName As String
'先保存图片
mFileName = "c:\tt.bmp"
SavePicture Picture1.Image, mFileName
fileNo = FreeFile()
'打开文件取出图形数据
Open mFileName For Binary As #fileNo
LenF = LOF(fileNo)
ReDim BMPData(LenF)
Get #fileNo, , BMPData
Close #fileNo
'保存到数据库中
With rs
.ActiveConnection = sConnection
.LockType = adLockOptimistic
.Open "select * from test "
.AddNew
'字段FID为一个 int 型的主键
'字段FData为一个image 型的字段
.Fields("FID") = InterID
.Fields("FData").AppendChunk BMPData
.Update
End With
rs.Close
Set rs = Nothing
End Sub
'得到
Private Sub cmdLoad_Click()
On Error GoTo H_Error
Dim rsData As New ADODB.Recordset
Dim strData As String, strBuffer As String
Dim LenF As Long
Dim BMPData() As Byte
'打开数据库
With rsData
.ActiveConnection = sConnection
.CursorLocation = adUseClient
.Open "select * from test"
'得到数据的长度
LenF = .Fields("FData").ActualSize
ReDim BMPData(LenF)
'得到图形文件的数据
BMPData = .Fields("FData").GetChunk(LenF)
End With
rsData.Close
Set rsData = Nothing
strBuffer = "c:\test.bmp"
If Dir(strBuffer) <> "" Then
Kill strBuffer
End If
Dim fileNo As Integer
fileNo = FreeFile()
Open strBuffer For Binary As #fileNo
Put #fileNo, , BMPData
Close #fileNo
Picture1.Picture = LoadPicture(strBuffer)
Exit Sub
H_Error:
Debug.Assert False
End Sub
Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset
Dim InterID As String
Dim strData As String
Dim fileNo As Integer
Dim LenF As Long
Dim BMPData() As Byte
Dim mFileName As String
'先保存图片
mFileName = "c:\tt.bmp"
SavePicture Picture1.Image, mFileName
fileNo = FreeFile()
'打开文件取出图形数据
Open mFileName For Binary As #fileNo
LenF = LOF(fileNo)
ReDim BMPData(LenF)
Get #fileNo, , BMPData
Close #fileNo
'保存到数据库中
With rs
.ActiveConnection = sConnection
.LockType = adLockOptimistic
.Open "select * from test "
.AddNew
'字段FID为一个 int 型的主键
'字段FData为一个image 型的字段
.Fields("FID") = InterID
.Fields("FData").AppendChunk BMPData
.Update
End With
rs.Close
Set rs = Nothing
End Sub
'得到
Private Sub cmdLoad_Click()
On Error GoTo H_Error
Dim rsData As New ADODB.Recordset
Dim strData As String, strBuffer As String
Dim LenF As Long
Dim BMPData() As Byte
'打开数据库
With rsData
.ActiveConnection = sConnection
.CursorLocation = adUseClient
.Open "select * from test"
'得到数据的长度
LenF = .Fields("FData").ActualSize
ReDim BMPData(LenF)
'得到图形文件的数据
BMPData = .Fields("FData").GetChunk(LenF)
End With
rsData.Close
Set rsData = Nothing
strBuffer = "c:\test.bmp"
If Dir(strBuffer) <> "" Then
Kill strBuffer
End If
Dim fileNo As Integer
fileNo = FreeFile()
Open strBuffer For Binary As #fileNo
Put #fileNo, , BMPData
Close #fileNo
Picture1.Picture = LoadPicture(strBuffer)
Exit Sub
H_Error:
Debug.Assert False
End Sub
解决方案 »
- 存储过程参数前加N
- 如何通过一个IP判断这个IP是否是代理服务器的IP
- 提个简单的问题
- 求工作日历的存贮过程或者函数?
- 如何将一个变量作为一个列插入select的结果中??具体问题内详~~
- 小于一个时间的总数汇总,我实在想不到了。
- 关于Microsoft SQL Server Management Studio Express建立表映射的疑问 路过的帮帮忙
- 数据库根据主表的编号 查询子表的数据 汇总
- 请教一条sql语句
- 我的sql起不来了,应该是DTC的问题,怎么办?非常急!
- 关于SQLServerAgent启动不了的问题
- 请问在VFP(或其它WINDOWS环境下的编程语言环境下)如何控制中断?
1。图片保存到SQL SERVER,是否很占空间。
2。存取时的速度如何。请vcchen调试成功后,告知。[email protected]
"没有压缩当然是有多大就占用多少空间"中的“压缩”指什么
如何实现
在保存之前先调用一个控件对文件进行压缩
然后保存压缩后的文件
在打开时进行取数-->保存--->解压缩还原
我推荐ActiveZip Control Version 2.0挺好支持Winzip