prisilla jayaraj

prisilla jayaraj

  • NA
  • 35
  • 102.2k

storing the image in database

Mar 10 2011 9:49 AM
FileUpload img = (FileUpload)FileUpload4;
Byte[] imgByte = null;
if (img.HasFile && img.PostedFile != null)
{

HttpPostedFile File = FileUpload4.PostedFile;

imgByte = new Byte[File.ContentLength];

File.InputStream.Read(imgByte, 0, File.ContentLength);

}



con.Open();
     string sql = "INSERT INTO randomimage VALUES(@imgexplain,@imgtype)";
SqlCommand cmd1 = new SqlCommand(sql, con);


cmd1.Parameters.AddWithValue("@imgexplain", TextBox7.Text.Trim());

cmd1.Parameters.AddWithValue("@imgtype", imgByte);


int id = Convert.ToInt32(cmd1.ExecuteNonQuery());

Label17.Text = String.Format("Success to add");

this is the coding i using for storing the image ,when i display that how can i reduce the size of it? 

plese tell me








Answers (3)