datagridview无法打开图像 [英] datagridview can not open an image
本文介绍了datagridview无法打开图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,如果您可以帮助我或为我提供建议的话
我有一张桌子名叫droducts;
在产品中插入值(''a1'',45,''ds'',''C:\ Documents and Settings \ AdministratorDesktop \ 1454251_5.jpg'');
我想在我的datagridviewer1中查看我的数据
但是有错误,它显示除图像以外的所有行,并且有错误.
我的代码是
hello if you can help me or advise me something
i have table named droducts;
insert into products values(''a1'',45,''ds'',''C:\Documents and Settings\AdministratorDesktop\1454251_5.jpg'');
and i want to see my datas in my datagridviewer1
but there is errot it shows evry row except image and there is error.
my code is
************************************
private DataSet ds = new DataSet();
private DataTable dt = new DataTable();
private DataSet dss = new DataSet();
private DataTable dtt = new DataTable();
********************************
NpgsqlCommand command = connection.CreateCommand();
NpgsqlDataReader Reader;
connection.Open();
string commanda = "SELECT * FROM products";
NpgsqlDataAdapter da = new NpgsqlDataAdapter(commanda, conn);
ds.Reset();
da.Fill(ds);
dt = ds.Tables[0];
dataGridView2.DataSource = dt;
请帮助我...
please hepl me...
推荐答案
好吧,您正在将图像路径保存到数据库,而不是图像本身.当数据从数据库返回以填充适配器时,它只是带有路径的字符串,并且不知道它应该是图像.
Well, you are saving the image path to the database and not the image itself. When the data comes back from the database to fill the adapter, it is just a string with the path, and has no idea that it is supposed to be an image.
这很明显...但是我能做什么呢?我想在我的数据网格中保存图片...这将在我的数据库中...:(
aha it is clear... but what do i can in order to do this? i want image in my datagrid... which will be in my database...:(
这篇关于datagridview无法打开图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文