Query image from database, and save to local?
Hi all,
I'm querying an email address and an image field. I need to save the image field to my local where the name is in the form of
<email address>.jpeg.
I think some conversion is necessary through Bitmap. I've never done this before and am having problems with it. If you could tell me what I'm doing wrong, I would greatly appreciate it.
SqlCommand query = new SqlCommand("SELECT a.email, b.image01 from empmast a, picture b where a.perno = b.perno");
query.Connection = con;
SqlDataAdapter mysqldataadapter = new SqlDataAdapter();
mysqldataadapter.SelectCommand = query;
DataSet mydataset = new DataSet();
con.Open();
mysqldataadapter.Fill(mydataset, "email");
DataTable mydataTable = mydataset.Tables["email"];
foreach (DataRow DR in mydataTable.Rows)
{
//Bitmap bmp1 = CreateBitmapImage(DR[1].ToString());
Bitmap bmp1 = new Bitmap(DR[1]);
bmp1.Save("c:\\image\\" + DR[0] + ".Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
}