1
我想從SQL表中檢索圖像並將其保存在列表中,並在我的列表視圖中顯示它。但我不知道該怎麼做。我需要你的幫助。使用數據庫中的圖像填充列表
我正在使用SQL Server 2008,Visual Studio 2008,C#窗口應用程序。
這裏是我的代碼:
cmd = new SqlCommand("Select ScanImage from ScanDocuments", con);
dr = cmd.ExecuteReader();
List<ImageList> lstitem = new List<ImageList>();
while (dr.Read())
{
ImageList _image = new ImageList();
byte[] data = (byte[])dr["ScanImage"];
MemoryStream ms = new MemoryStream(data);
Image bmp = new Bitmap(ms);
lstitem.Add(bmp);
}
向我們展示您自己的一些努力!你試過什麼了?你卡在哪裏?你遇到的問題是什麼? –
請看我編輯的問題。我在lstitem.add(bmp)出錯。 –