3
Answers

storing the image in database

prisilla jayaraj

prisilla jayaraj

13y
11.2k
1
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)