如何更新数据库中的图像 [英] How to UPDATE Image in Database

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

问题描述

我能够从数据库中添加和检索图像.
问题:我想更新数据库中的图像,即用从数据库中检索到的新图像或相同图像替换现有图像.

我正在使用此代码从数据库及其工作中检索图像,

I am able to add and retrieve image from database.
PROBLEM: I want to update image in database i.e. to replace the existing image with the new one or the same which i have retrieved from the database.

I am using this code to retrieve image from database and its working,

MemoryStream ms = new MemoryStream((byte[])dr["Photo"]);
curImage = Image.FromStream(ms);
pbImage.Image = curImage;



我正在使用此代码更新数据库中的图像,但它不起作用,



I am using this code to update image in database and its not working,

FileStream file = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read);
byte[] rawdata = new byte[file.Length];
file.Read(rawdata, 0, System.Convert.ToInt32(file.Length));
file.Close();
cmdSave.Parameters.Add(new SqlParameter("@photo", rawdata));



假设用户不想更新图像,他只想更新其他值,例如name,contactno.等等,当用户单击更新按钮时,现有图像应与其他值一起得到更新

我所需要做的就是用检索到的相同图像或新图像更新数据库中的图像.

我还没有解决方案.第一个答案不是解决办法.
请帮忙... asap



Suppose the user doesn''t want to update image, he just want to update other values such as name,contactno. etc and when the user clicks the update button the existing image should get updated along with other values

All i need is to update the image in database with the same image that i have retrieved or with a new image.

I have not got the solution yet. The 1st answer is not the solution.
please help...asap

推荐答案

也许发布一些代码?

判断它是否不起作用"有点困难!
Perhaps post some code?

''It''s not working'' is a bit difficult to determine !


我正面临着同样的问题……请任何人都可以帮助我们!!!?
I''m facing the same problem... please any one can help us!!!!?


我也需要有关此问题的帮助.
有人有代码怎么做吗
i need help on this problem as well.
does anyone have the code how to do it


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

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