下面代码能运行,但保存不进内容 On Error GoTo err
Dim StmPic As ADODB.Stream Set StmPic = New ADODB.Stream
StmPic.Type = adTypeBinary
StmPic.Open
StmPic.LoadFromFile (P_SelFilePath)
M_adoRS.AddNew
M_adoRS.Fields("Pic").Value = StmPic.Read (此处不能保存,有时保存什么也没有)
M_adoRS.Update
StmPic.Close
Exit Sub
err:
MsgBox err.Description
Dim StmPic As ADODB.Stream Set StmPic = New ADODB.Stream
StmPic.Type = adTypeBinary
StmPic.Open
StmPic.LoadFromFile (P_SelFilePath)
M_adoRS.AddNew
M_adoRS.Fields("Pic").Value = StmPic.Read (此处不能保存,有时保存什么也没有)
M_adoRS.Update
StmPic.Close
Exit Sub
err:
MsgBox err.Description
M_adoRS.Fields("Pic").Value = StmPic.Read 我感觉没有指定读取的大小就问题,我建议用2进制的方式写入数据库,在写入前,先把图片的2进制数据读出来,然后保存,文件的2进制方式读取文件,楼主应该会吧,记住一定要把整个文件的内容都读出来.
再读取数据库的时候,先读3进制,然后一次写入图像文件中,就不会有问题了.