请教各位,在VB中怎样使用SQL语句更新数据库(SQL Server2000)中的图片.
在插入图片时我调用了一个函数然后向数据库中写入图片文件,当要新数据库中的图片文件时是不是也要调用该函数?应该怎样调用?如果不是,那该怎么样更新?大家救救我吧.
谢谢!!调用的函数为:'声明
Dim SchoolCnn As String
Dim FileName As String
Dim ADOFld As ADODB.Field
Const BLOCKSIZE = 4096
'函数
Private Sub SaveToDB(ByRef Fld As ADODB.Field, DiskFile As String)
Dim byteData() As Byte '定义数据块数组
Dim NumBlocks As Long '定义数据块个数
Dim FileLength As Long '标识文件长度
Dim LeftOver As Long '定义剩余字节长度
Dim SourceFile As Long '定义自由文件号
Dim i As Long '定义循环变量
SourceFile = FreeFile '提供一个尚未使用的文件号
Open DiskFile For Binary Access Read As SourceFile '打开文件
FileLength = LOF(SourceFile) '得到文件长度
If FileLength = 0 Then '判断文件是否存在
Close SourceFile
MsgBox DiskFile & "无内容或不存在!"
Else
NumBlocks = FileLength \ BLOCKSIZE
LeftOver = FileLength Mod BLOCKSIZE
ReDim byteData(BLOCKSIZE)
For i = 1 To NumBlocks
Get SourceFile, , byteData()
Fld.AppendChunk byteData()
Next i
ReDim byteData(LeftOver)
Get SourceFile, , byteData()
Fld.AppendChunk byteData()
Close SourceFile
End If
End Sub
在插入图片时我调用了一个函数然后向数据库中写入图片文件,当要新数据库中的图片文件时是不是也要调用该函数?应该怎样调用?如果不是,那该怎么样更新?大家救救我吧.
谢谢!!调用的函数为:'声明
Dim SchoolCnn As String
Dim FileName As String
Dim ADOFld As ADODB.Field
Const BLOCKSIZE = 4096
'函数
Private Sub SaveToDB(ByRef Fld As ADODB.Field, DiskFile As String)
Dim byteData() As Byte '定义数据块数组
Dim NumBlocks As Long '定义数据块个数
Dim FileLength As Long '标识文件长度
Dim LeftOver As Long '定义剩余字节长度
Dim SourceFile As Long '定义自由文件号
Dim i As Long '定义循环变量
SourceFile = FreeFile '提供一个尚未使用的文件号
Open DiskFile For Binary Access Read As SourceFile '打开文件
FileLength = LOF(SourceFile) '得到文件长度
If FileLength = 0 Then '判断文件是否存在
Close SourceFile
MsgBox DiskFile & "无内容或不存在!"
Else
NumBlocks = FileLength \ BLOCKSIZE
LeftOver = FileLength Mod BLOCKSIZE
ReDim byteData(BLOCKSIZE)
For i = 1 To NumBlocks
Get SourceFile, , byteData()
Fld.AppendChunk byteData()
Next i
ReDim byteData(LeftOver)
Get SourceFile, , byteData()
Fld.AppendChunk byteData()
Close SourceFile
End If
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货