Store and retrieve video filed in database

How to store and retrieve video files using .net

Page 1 of 1

2 Replies - 10971 Views - Last Post: 01 February 2008 - 06:32 AM Rate Topic: -----

#1 revathi174  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 01-February 08

Store and retrieve video filed in database

Posted 01 February 2008 - 01:04 AM

Hello,
could anyone help how to store the video files in the database and to retrieve them from the database and play them using .net
Is This A Good Question/Topic? 1

Replies To: Store and retrieve video filed in database

#2 pabs1983  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 37
  • Joined: 14-December 06

Re: Store and retrieve video filed in database

Posted 01 February 2008 - 06:25 AM

Its not wise to store videos in a database. It would be far easier to set up a file upload to a folder on your system and store the location of the video in the database.

Try this for the upload to a folder on your website

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload.aspx.cs" Inherits="upload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		<asp:FileUpload ID="FileUpload1" runat="server" />
	</div>
	<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
	</form>
</body>
</html>


Code Beind
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class upload : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
	protected void Button1_Click(object sender, EventArgs e)
	{
		if (FileUpLoad1.HasFile)
		{

			FileUpLoad1.SaveAs(@"C:\temp\" + FileUpLoad1.FileName);
			Label1.Text = "File Uploaded: " + FileUpLoad1.FileName;
		}
		else
		{
			Label1.Text = "No File Uploaded.";
		}
	}
}




It may need some 'editing' to suit your needs.
Was This Post Helpful? 1
  • +
  • -

#3 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,559
  • Joined: 25-January 07

Re: Store and retrieve video filed in database

Posted 01 February 2008 - 06:32 AM

You can store your video files on some file server and store their paths in database [if you think you need to keep them as they are needed to modify time to time], because making file will cause repeated updates in files. So you can extract paths from database for appropriate videos and load them from file server. Or yes you can try xml instead of database. I am not expert in .net to please take a call yourself about which way to go.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1