其实,直接用insert就可以了。
Dim sTemp As String
sTemp = "insert into mypic(pic) values(?)"
dim PicB() as byte
dim FileID as long
fileid=freefile
open "c:/test.bmp" for binary access read as #fileid
redim picb(lof(fileid))
get fileid,picb
close #fileid
dim Con as new connection
dim CMD as new command
con.connectionstring ="数据库连接字符串"
con.open
cmd.activeconnection=con
cmd.commandtext= stemp
cmd.commandtype=adcmdtext
cmd.parameters(0).type=adbinary
cmd.parameters(0).value=picb
cmd.execute
con.close
set cmd=nothing
set con=nothing
代码很简单,不需要多解释。
程序在VB6+sql Server上测试通过。
原文链接:https://www.f2er.com/vb/263350.html