How can i upload video files to sqlserver 2005. How can i do this task?
Regards,
Manu.
Video files upload
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lalit MRank #1,186 · 1.5K reputationPosted Dec 5, 2009, 1:55 AM EST
You can try this code sample protected void Button1_Click(object sender, EventArgs e) { //put these connection code here instead of pageload. string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString; sqlcon = new SqlConnection(connectionString); sqlcon.Open(); cmd1.Parameters.Add("@vid", SqlDbType.Int); cmd1.Parameters.Add("@vidfile", SqlDbType.VarBinary, 1000); cmd1.Parameters.Add("@vidname", SqlDbType.VarChar, 1000); if (FileUpload1.HasFile && FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { HttpPostedFile file = FileUpload1.PostedFile; string fn = FileUpload1.PostedFile.FileName; cmd1.Parameters["@vid"].Value = 1; buffer = new byte[file.ContentLength]; int bytesReaded = file.InputStream.Read(buffer, 0, FileUpload1.PostedFile.ContentLength); cmd1.Parameters["@vidfile"].Value = buffer; cmd1.Parameters["@vidname"].Value = fn; if (bytesReaded > 0) { try { cmd1.CommandText = "Insert into vidtable (vid, vidfile, vidname)" + "Values (@vid, @vidfile, @vidname)"; cmd1.Connection = sqlcon; int i = cmd1.ExecuteNonQuery(); Label1.Text = "uploaded, " + i.ToString() + " rows affected"; } catch (Exception ex) { Label1.Text = ex.Message.ToString(); } } } else { Label1.Text = "Choose a valid video file"; } }