如何将图像拉出数据库? [英] How to pull image out of database?

查看:87
本文介绍了如何将图像拉出数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SQL 2005中有一个数据库表,其中有一列图像(图像数据类型).图像是GIF.我可以编写一个VBScript并使用ADO写出图像,然后就可以打开它们了.当我使用ADO.Net时,该文件的大小加倍,并且不会打开.如果我使用ADO.net插入表中,则可以将其拉出.数据已使用ADO输入.

如何使用ADO.Net将图像从表中拉出并将其重新构造为GIF?

I have a database table in SQL 2005 with a column of images (image datatype). The images are GIFs. I can write a VBScript and write out the images using ADO and I can open them just fine. When I use ADO.Net, the file doubles in size and will not open. If I insert into the table using ADO.net, I can pull it out just fine. The data is/was put in using ADO.

How can I pull the images out of the table using ADO.Net and construct them back as GIFs? Is there some translation somewhere that I am missing?

推荐答案

在SQL Server 2005中,图像数据类型类似于字节数组.

因此,只要需要,就可以从数据库中以字节数组的形式检索数据并写入文件.要了解图像的MIME类型,您需要单独存储MIME类型.

我希望这能帮到您.

使用Microsoft .NET从SQL Server存储和检索图像 [
See in SQL Server 2005, image datatype is similar to Byte Arrays.

So just retrieve the data from the database as a Byte array and write to the file wheneever required. To understand the mimetype of the image, you need to store the mime type separately.

I hope this will help you.

Storing and Retrieving Images from SQL Server using Microsoft .NET[^]

:):rose:


我将其作为字节数组拉出并将其写入文件.不幸的是,当我使用.Net进行操作时,它的大小是使用ADO&VBScript所写出的同一图像的两倍.另外,使用ADO.Net编写的图像完全不是图像. ADO图像将正确呈现.
I am pulling it out as a byte array and writing it to a file. Unfortunately when I do that with .Net, it is twice the size of the same image written out using ADO & VBScript. Also, the image written using ADO.Net is not at all an image. The ADO image will render correctly.


这篇关于如何将图像拉出数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆