且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用存储过程方法使用c#从sql server数据库asp.net存储和检索图像

更新时间:2022-11-28 18:42:00

从文件加载图片后,你必须将其转换为bytes数组,然后将结果保存到SQL表中的image字段中。要从DB加载图像,你应该以相反的方式加载。


我更喜欢的另一种方法是只存储数据库中图像的路径并将图像放在某处您的IIS服务器。


请阅读 thread 作为数据库中基本保存和检索图像的参考。 。 。 。

希望它会有所帮助。

I need a help.i am developing product details project.so i am insert and retrieve product images from sql server database.i don't know this concept.

please help me


After you loading the image from file, you have to convert it to bytes array, then save the result into a "image" filed in your SQL table. To load the image from DB you should do in the reverse way.


Another way, which I prefer, is to just store the path to the image in the database and have the images somewhere on your IIS server.


Please read this thread as your reference for basic save and retrieve of images in database. . . .
hope it will help. .