大佬教程收集整理的这篇文章主要介绍了Mysql 存储过程返回 blob 为空,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将 blob 记录(图像)从 MysqL 数据库获取到 vba 用户表单图片图像。
@H_868_2@mysqL 表 "images" 具有结构 = ID int,image1 blobmedium。 如果我使用SELECT ID,image1 FROM images
我明白了:
SELEct statement returns id and also blob column
我编写了 MysqL 存储过程 GetimageNow 来从数据库中获取这个 blob(图像):
DEliMITER //
CREATE PROCEDURE GetimageNow()
BEGIN
SELECT ID,image1 FROM images;
END //
DEliMITER ;
当我运行此过程时,它在 image1 列中返回 null。我不明白为什么
stored procedure returns null in blobmedium column
好的。谢谢你的建议。最后我得到了从数据库读取图像并将其加载到用户表单上的图片框的代码:
Private Sub ReadImageFromDB ()
Dim cnSqlConn As New ADODB.Connection
cnSqlConn.ConnectionString = "DSN=XXX"
cnSqlConn.open
/* create command for running mysql stored procedure GetImage */
Dim cmd As New ADODB.Command
With cmd
.ActiveConnection = cnSqlConn
.CommandType = adCmdStoredProc
.CommandText = "GetImage"
.CommandTimeout = 15
End With
/* read blob image from database via ADODB.Stream and save it temporarily on disk*/
Dim rsImage as New ADODB.Recordset
Set rsImage = cmd.Execute
Dim stm As New ADODB.Stream
With stm
.Type = adTypeBinary
.open
.Write rsImage.Fields("image1").Value
.SaveToFile "d:\Temp.jpg",adSaveCreateOverWrite
End With
/* load the picturE into Image on userform */
Userform1.imgImageFromDatabase.Picture = LoadPicture("d:\temp.jpg")
Kill ("d:\temp.jpg")
rsImage.Close
Set rsImage = Nothing
cnSqlConn.Close
Set cnSqlConn = Nothing
Set stm = Nothing
End Sub
以上是大佬教程为你收集整理的Mysql 存储过程返回 blob 为空全部内容,希望文章能够帮你解决Mysql 存储过程返回 blob 为空所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。