查询二进制格式存入access数据库

lzfile 2003-05-16 10:44:15
我将一段文本数据(文本包含字符‘我的文件’)以二进制格式存入access数据库的长二进制字段TXTINFO中,如何用SQL语句从字段TXTINFO查询到所有包含‘我的文件’的纪录呢?
...全文
14 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lihonggen0 2003-05-16
Private Function DatabaseToFile(ByVal DataField As ADODB.Field, ByVal vSaveAs As String, ByVal vFileExpendName As String) As String
Dim fnum As Long, bytesleft As Long, bytes As Long
Dim lSumSize As Long, lNowSize As Long
Dim tmp() As Byte
On Error GoTo ErrHandleDatabaseToFile
If Trim(vSaveAs) = "" Then
DatabaseToFile = GetTempFileName(vFileExpendName)
Else
DatabaseToFile = Trim(vSaveAs)
End If

fnum = FreeFile
Open (DatabaseToFile) For Binary As fnum
bytesleft = DataField.ActualSize

lSumSize = CLng(bytesleft / 8192)

Do While bytesleft
bytes = bytesleft
If bytes > 8192 Then bytes = 8192
tmp = DataField.GetChunk(bytes)
Put #fnum, , tmp
bytesleft = bytesleft - bytes
lNowSize = lNowSize + 1
RaiseEvent TransmitData(lNowSize, lSumSize, False)
Loop
Close #fnum
Exit Function
ErrHandleDatabaseToFile:
DatabaseToFile = ""
Err.Clear
End Function

Private Function FileToDatabase(ByVal vDataField As ADODB.Field, ByVal vFileName As String)
Dim fnum As Long, bytesleft As Long, bytes As Long
Dim lSumSize As Long, lNowSize As Long
Dim tmp() As Byte
On Error GoTo ErrHandleFileToDatabase

fnum = FreeFile
Open vFileName For Binary As fnum
bytesleft = LOF(fnum)
lSumSize = CLng(bytesleft / 8192)
Do While bytesleft
bytes = bytesleft
If bytes > 8192 Then bytes = 8192
ReDim tmp(1 To bytes) As Byte
Get #fnum, , tmp
vDataField.AppendChunk tmp
bytesleft = bytesleft - bytes
lNowSize = lNowSize + 1
DoEvents
RaiseEvent TransmitData(lNowSize, lSumSize, True)
Loop

Close #fnum

Exit Function
ErrHandleFileToDatabase:
Err.Clear
End Function

回复
lihonggen0 2003-05-16
http://www.china-askpro.com/msg9/qa42.shtml
回复
lihonggen0 2003-05-16
http://www.dapha.net/down/list.asp?id=601

文本文件转换到数据库
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7490

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-16 10:44
社区公告
暂无公告