图片如何加载到access数据库中及如何调用

hmeidao 2003-08-25 11:03:04
回家了好久没有来了,现在一回学校就有问题了。
麻烦各位高手给我详细解答哦,在下谢谢了:
图片如何加载到access数据库中及如何调用
...全文
127 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lye 2003-08-25
  • 打赏
  • 举报
回复
下面是stream的使用祥解:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q258/0/38.asp&NoWebContent=1
lihonggen0 2003-08-25
  • 打赏
  • 举报
回复
将图片写入数据库并显示
http://www.dapha.net/down/list.asp?id=1826
lye 2003-08-25
  • 打赏
  • 举报
回复
在ADO里面有一个Stream对象,可以实现对数据流的读写.
liul17 2003-08-25
  • 打赏
  • 举报
回复
去以下几个页面看看

http://www.china-pub.com/computers/emook/1162/info.htm

http://www.zjedu.org/xdjyjs/98/2082.htm

lxqlogo0 2003-08-25
  • 打赏
  • 举报
回复
Access 中是 OLE 对象的字段
Private Sub DBOpen()

'open the database with ADO

MYcon.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=" & App.Path + "/DBpic.MDB"

MYrs.Open "PICTABLE", MYcon, 1, 3



End Sub

'Close the open database

Private Sub DBClose()

MYrs.Close

MYcon.Close

Set MYrs = Nothing

Set MYcon = Nothing

End Sub



Private Sub SaveInto(ByVal strPath As String)



Dim lngFileLength As Long 'the length of the file

Dim lngBlockCount As Long 'the number of total whole block

Dim lngLastBlock As Integer 'the length of the last block

Dim lngBlockIndex As Long 'the index of each block

Dim ByteGet() As Byte '用于传送数据的二进制数组

Dim FileNum As Integer 'return the file number which the next file will use

Dim strFilepath As String



strFilepath = strPath

FileNum = FreeFile()



Open strFilepath For Binary Access Read As #FileNum

lngFileLength = LOF(FileNum) '返回一个 Long,表示用 Open 语句打开的文件的大小,该大小以字节为单位。

lngBlockCount = lngFileLength \ lngBlockSize

lngLastBlock = lngFileLength Mod lngBlockSize



MYrs.AddNew

MYrs.Fields("size") = lngFileLength

MYrs.Fields("date") = Date

MYrs.Fields("name") = Trim(Text1)

ReDim ByteGet(lngBlockSize)

For lngBlockIndex = 1 To lngBlockCount

Get #FileNum, , ByteGet()

MYrs.Fields("pic").AppendChunk ByteGet()

Next



If lngLastBlock > 0 Then

ReDim ByteGet(lngLastBlock)

Get #FileNum, , ByteGet()

MYrs.Fields("pic").AppendChunk ByteGet()

End If

MYrs.Update

Close #FileNum

End Sub



Private Sub ShowImg(ByVal RecordPoint As Long)

On Error Resume Next



Dim temp_path As String

Dim temp_file As String

Dim length As Long

Dim lngFileLength As Long 'the length of the file

Dim lngBlockCount As Long 'the number of total whole block

Dim lngLastBlock As Integer 'the length of the last block

Dim lngBlockIndex As Long 'the index of each block

Dim ByteGet() As Byte '用于传送数据的二进制数组

Dim FileNum As Integer 'return the file number which the next file will use

Dim strFileName As String



temp_path = Space$(MAX_PATH)

length = GetTempPath(MAX_PATH, temp_path)

temp_path = Left$(temp_path, length)

temp_file = Space$(MAX_PATH)

GetTempFileName temp_path, "per", 0, temp_file

strFileName = Left$(temp_file, InStr(temp_file, Chr$(0)) - 1)



MYrs.MoveFirst

MYrs.Move RecordPoint

Label1 = MYrs.AbsolutePosition

frmMain.Caption = MYrs.Fields("name") + Str(i)

FileNum = FreeFile()

Open strFileName For Binary As #FileNum

lngFileLength = MYrs.Fields("size")

lngBlockCount = lngFileLength \ lngBlockSize

lngLastBlock = lngFileLength Mod lngBlockSize

For lngBlockIndex = 1 To lngBlockCount

ByteGet() = MYrs.Fields("pic").GetChunk(lngBlockSize)

Put #FileNum, , ByteGet()

Next

If lngLastBlock > 0 Then

ReDim ByteGet(lngLastBlock)
ByteGet() = MYrs.Fields("pic").GetChunk(lngBlockSize)
Put #FileNum, , ByteGet()
End If
Picture1.Picture = LoadPicture(strFileName)
Close #FileNum
Kill strFileName
Err.Clear
End Sub
Private Sub AimFilePath(ByVal strPath As String)
Dim PathVal As String
PathVal = Dir(strPath)
If PathVal = Null Then MsgBox "null"
Do While PathVal <> ""
SaveInto (strPath + PathVal)
PathVal = Dir
Loop
End Sub



7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧