protected void Button2_Click(object sender, EventArgs e) { if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { byte[] imageSize = new byte[FileUpload1.PostedFile.ContentLength]; HttpPostedFile uploadedImage = FileUpload1.PostedFile; uploadedImage.InputStream.Read (imageSize, 0, (int)FileUpload1.PostedFile.ContentLength); // Create SQL Connection SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=PROMOD-PC;Initial Catalog=travel_Directions;Integrated Security=True"; SqlCommand DbPath = new SqlCommand(); DbPath.CommandText = "INSERT INTO MyMapDb(image_Upload)" + " VALUES (@image_Upload)"; DbPath.CommandType = CommandType.Text; DbPath.Connection = con; SqlParameter ImageUpload = new SqlParameter("@image_Upload", SqlDbType.Image, imageSize.Length); ImageUpload.Value = imageSize; ImageUpload.Value = imageSize; DbPath.Parameters.Add(ImageUpload); con.Open(); DbPath.ExecuteNonQuery(); con.Close(); Image1.DataBind(); // image will load to this image controller } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)