string strImageName = TextBox3.Text.ToString(); 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 con = new SqlConnection(connstring); // Create SQL Command SqlCommand cmd = new SqlCommand(); cmd.CommandText = "INSERT INTO Images(ImageName,Image)" + " VALUES (@ImageName,@Image)"; cmd.CommandType = CommandType.Text; cmd.Connection = con; SqlParameter ImageName = new SqlParameter ("@ImageName", SqlDbType.VarChar, 50); ImageName.Value = strImageName.ToString(); cmd.Parameters.Add(ImageName); SqlParameter UploadedImage = new SqlParameter ("@Image", SqlDbType.Image, imageSize.Length); UploadedImage.Value = imageSize; cmd.Parameters.Add(UploadedImage); con.Open(); int result = cmd.ExecuteNonQuery(); con.Close(); if (result > 0) Label1.Text = "File Uploaded"; Image1.DataBind(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)