Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何通过VB.NET在sql server数据库中存储和检索图像_Sql Server_Database_Vb.net - Fatal编程技术网

Sql server 如何通过VB.NET在sql server数据库中存储和检索图像

Sql server 如何通过VB.NET在sql server数据库中存储和检索图像,sql-server,database,vb.net,Sql Server,Database,Vb.net,SQL Server支持客户端存储 表中的对象 创建数据类型为图像的字段,并初始使用空值初始化字节数组。使用FileInfo对象获取文件大小。打开FileStream读取文件。使用在此处发布之前进行一点谷歌搜索。下面是我为您的查询得到的第三个搜索结果。我知道怎么做,但没有足够的耐心再做一次。下面是来自 SQL Server中的图像字段只是一个字节数组。下面是您需要的重要代码。假设数据库中图像字段的名称为“imageField”。希望这有帮助 要检索图像并将其保存到磁盘,请执行以下操作: //dr

SQL Server支持客户端存储 表中的对象


创建数据类型为图像的字段,并初始使用空值初始化字节数组。使用FileInfo对象获取文件大小。打开FileStream读取文件。使用在此处发布之前进行一点谷歌搜索。下面是我为您的查询得到的第三个搜索结果。我知道怎么做,但没有足够的耐心再做一次。下面是来自


SQL Server中的图像字段只是一个字节数组。下面是您需要的重要代码。假设数据库中图像字段的名称为“imageField”。希望这有帮助

要检索图像并将其保存到磁盘,请执行以下操作:

//dr is a DataReader returned from a SELECT command
Dim imageInBytes As Byte() = dr("imagefield")
Dim memoryStream As System.IO.MemoryStream = _ 
    New System.IO.MemoryStream(imageInBytes, False)
Dim image As System.Drawing.Image = _ 
    System.Drawing.Image.FromStream(memoryStream)
image.Save("c:\image")
要将映像从磁盘保存到SQL Server,请执行以下操作:

''Get the image file into a Byte Array
Dim image As Byte() = System.IO.File.ReadAllBytes("c:\image.jpg")
''Add the byte array as a parameter to your Insert/Update SQLCommand
parameters.Add("@ImageField", image)
''Get the image file into a Byte Array
Dim image As Byte() = System.IO.File.ReadAllBytes("c:\image.jpg")
''Add the byte array as a parameter to your Insert/Update SQLCommand
parameters.Add("@ImageField", image)