我们知道ImageKit v9在文件的处理方面进行了改进,其中新增BLOB图像数据可保存到数据库的功能,那么如何从数据库中加载图像数据呢?今天分享如何在数据库中检索图像数据。
下面是示例代码,可供参考
Dim BinaryData() As Byte Dim connStr As String Dim ID As String Dim rs As Recordset connStr="driver=SQLServer;DATABASE=MyDatabase;UID=MyUserid;_<br> PWD=MyPassword;Server=MyServer" Set rs = CreateObject("ADODB.Recordset") ID = "001" rs.Open "select ImageData from Files where ID =" + ID, connStr, 2, 4 BinaryData = rs("ImageData") 'retrieve BLOB data rs.Close Set rs = Nothing 'Set the BLOB data into the ImageKit Control ImageKit1.File.LoadFromStream BinaryData ImageKit1.File.LoadFileMem ikLoad 'Load as DIB data ImageKit1.Display ikScale 'Display in the ImageKit Control
了解更多ImageKit