从C#中的Access数据库添加和检索图像 [英] add and retriving image from access database in C#
本文介绍了从C#中的Access数据库添加和检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Microsoft Access数据库添加和检索图像,以及如何使用C#WinForms检索它们?
How can I add and retrieve images from Microsoft Access database and also retrieve them using C# WinForms?
推荐答案
将图像转换为byte []并插入类型为image的列中. 虽然检索检查不为null,然后从数据读取器中读取并类型转换为byte [].
Convert image into byte[] and insert into column of type image. While retrieve check is not null and then read from datareader and typecast into byte[].
if (dr["Image"] != DBNull.Value && dr["Image"] != null)
{
Image = (byte[])dr["Image"];
}
从byte []您可以转换为图像
From byte[] you can convert into image
Image img;
Image.FromStream(new MemoryStream(m_Image));
这篇关于从C#中的Access数据库添加和检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文