如何在SQL 2008中插入图像 [英] how to insert image in sql 2008

查看:96
本文介绍了如何在SQL 2008中插入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在sql database2008中插入图像.... am直接使用sql数据表插入数据而不是查询.我在插入具有该类型数据类型的图像时遇到了问题....实际上我想拥有图像及其从数据库到前端ASP.NET的数据,使用C#.

how can i insert image in sql database2008 ....Iam using sql data table directly for inserting data instead of query .i am facing problem in inserting image with data type for that .....Actually i want to have image and its data from database to the front end asp .net using C#.

推荐答案

您必须将图像转换为字节数组并将其传递给数据库那样.检索图像时,它将以字节数组的形式出现,然后您必须将其转换回图像.

如果您使用Google进行搜索,有很多示例.
You have to convert the image into an array of bytes and pass it to your database that way. When you retrieve the image, it will come over as an array of bytes that you then have to convert back to an image.

There are plenty of examples if you google it.


您尝试了什么? SQL 2008中有一个Image数据类型.您是否尝试过使用它?
What have you tried? There is a Image datatype in SQL 2008. Have you tried using that?


正如其他人所说,插入图像非常简单.真正的窍门是再次获得图像.您需要编写一个页面,该页面根据数据库中的id返回图像的字节,然后将其用作代码中图像的URL.您也可以根据需要编写HTTP处理程序.
As others have said, inserting an image is pretty trivial. The real trick is getting the image out again. You need to write a page that returns the bytes of an image based on the id in the DB, and then use that as the URL to an image in your code. You can also write a HTTP handler if you prefer.


这篇关于如何在SQL 2008中插入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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