如何使用文件夹中的图像和数据库中的数据加载DataTable? [英] How to Load DataTable with images from folder and data from database?

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

问题描述

我在一个文件夹中有图像。

一个表中数据库中的员工信息。

员工在另一个表中显示信息。



我需要在asp:gridview中使用c#一次显示它们。



我可以做任何一件事只是,而不是两者同时。



那么,怎么做?

解决方案

将图像保存到一个带有数据库字段引用的文件夹中。



喜欢:img_id.jgg / [img_1.jpg,img_2.jpg,img_3.jpg]



然后从表中获取所有数据并为每行构建图像路径





DataTable dt = sql.ExecuteDataTable(sp_MyProc);



dt.Columns.Add(MyImagePath,type(System.String));



foreach(DataRow dr in dt.Rows)

{

//需要设置值为MyRow栏目

dr [MyImagePath] =/ FolderN ame /+ img_ + dr [Id] +。jpg;

}



希望这对你有用

查看此链接可能对您有用.. 如何存储&使用asp.net c#在mysql数据库中检索图像[ ^ ]谢谢你。


I have images in a folder.
The employee information in the database in one table.
The employees picture information in another table.

I need to show both of them at once in asp:gridview using c#.

I am able to do the either thing only, not the both at the same time.

So, how to do this?

解决方案

Save your Images into a folder with a reference from the database field.

Like : img_id.jgg / [ img_1.jpg , img_2.jpg, img_3.jpg]

Then get all data from the table and build your image path for each row


DataTable dt = sql.ExecuteDataTable("sp_MyProc");

dt.Columns.Add("MyImagePath", type(System.String));

foreach(DataRow dr in dt.Rows)
{
//need to set value to MyRow column
dr["MyImagePath"] = "/FolderName/"+img_+dr["Id"]+.jpg;
}

Hope this will work for you


See this link may useful to u..How to store & retrieve images in mysql database using asp.net c#[^]thank u.


这篇关于如何使用文件夹中的图像和数据库中的数据加载DataTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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