Convert image to Bitmap, and save to local

fralo

New member
Joined
Jan 25, 2012
Messages
1
Programming Experience
3-5
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);
}

 
Top Bottom