kumar

kumar

  • NA
  • 13
  • 0

how to uplaod the image

Apr 2 2008 1:00 AM

hai i am using the following code to apply the watermark and save in specific location and then upload the image to  database as a binary

[ byte[] img1 = new byte[fileupload1.postedfile.contentlength];
Httppostedfile image = fileupload1.postedfile;
image.Inputstream.read(img1,0,(int)fileupload1.postedfile.contentlength);
Bitmap bm1 = new bitmap(new system.IO.Memorystream(imd1));
Graphics grp = Graphics.FromImage(bm1);
grp.smoothingMode = smoothingMode.AntiAlise;
grp.Drawstring("name" ,new font("Arial",20),systemBrushes.WindowText,250,250);

string a1 = server.mapPath(@"image\\winteer1.jpg");
bm1.save(a1);
image1.imageurl=a1;
Bitmap a2 = new Bitmap(image1.imageurl);

up to this the program work's perfectly  while upload to the database i show the error ..


sql connection con = new sql connection (conn);
sql command com = new sqlcommand (insert into );
com.parameters.Addwith value("@image",a2);
con.open();
com.ExecuteNonquery();
con.close();

in that com.ExecuteNonquery() the error show's like (no mapping exits from object type system.drawing .Bimap to a known managed provider native type)

plz reply me ............


Answers (1)