473,378 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to retrieve video file from DB?

Expand|Select|Wrap|Line Numbers
  1. private DataTable GetVideoInfo()
  2.     {
  3.         string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
  4.         SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Videos", connectionString);
  5.         DataTable table = new DataTable();
  6.         adapter.Fill(table);
  7.         return table;
  8.     }
  9.  
  10.     private DataTable GetSpecificVideo(object i)
  11.     {
  12.         string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
  13.         SqlDataAdapter adapter = new SqlDataAdapter("SELECT Video, ID FROM Videos WHERE ID = @id", connectionString);
  14.         adapter.SelectCommand.Parameters.Add("@id", SqlDbType.Int).Value = (int)i;
  15.         DataTable table = new DataTable();
  16.         adapter.Fill(table);
  17.         return table;
  18.     }
  19.     protected void ButtonShowVideo_Click(object sender, EventArgs e)
  20.     {
  21.         Repeater1.DataSource = GetSpecificVideo(2);
  22.         Repeater1.DataBind();
  23.     } 
  24.  
  25.  
i have used videohandler for displaying video, and i think it cannot get video's id
here is my videohandler code
Expand|Select|Wrap|Line Numbers
  1. public void ProcessRequest (HttpContext context) 
  2.     {
  3.         string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
  4.  
  5.         SqlConnection connection = new SqlConnection(connectionString);
  6.         SqlCommand cmd = new SqlCommand("SELECT Video, Video_Name FROM Videos WHERE ID = @id", connection);
  7.         cmd.Parameters.Add("@id", SqlDbType.Int).Value = context.Request.QueryString["id"];
  8.         try
  9.         {
  10.             connection.Open();
  11.             SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
  12.             if (reader.HasRows)
  13.             {
  14.                 while (reader.Read())
  15.                 {
  16.                     context.Response.ContentType = reader["Video_Name"].ToString();
  17.                     context.Response.BinaryWrite((byte[])reader["Video"]);
  18.                 }
  19.             }
  20.         }
  21.         finally
  22.         {
  23.             connection.Close();
  24.         }
  25.     }
Dec 18 '10 #1
0 1070

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dafna m | last post by:
Can I present a video file as picture file? (By built-in class) Thanks, Dafna *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded...
0
by: Jason Ho | last post by:
Hi, Any API we can call to extract a frame from a video file (e.g. avi) as Bitmap format? I want to have a file browser to show thumbnail for video files. I think the .NET framework should...
3
by: rojavenkat81 | last post by:
Hi All, Please help me regarding php program for convert video file to .flv file. I searched in many sites but i got only tool to convert video file to .flv file.But I want convert...
0
by: shivavodnala | last post by:
hi , i have to retrieve a video file retrieve video file from sql server2000 database and it has to play on media player at browser,please send code
0
by: shivavodnala | last post by:
hi , i have to retrieve video file(.wmv) from sql server 2000 database and which has to play on media player at browser web page
1
by: Uday | last post by:
Hi Everybody, I am building a website in Asp.Net 1.1. I need to play a video file in the site. How to do this. Please help me out. Thanks in Advance Uday Mandava
3
by: aratimane | last post by:
Hi, I have received the video file in chunk and want to join/merge these chunks into one video file. I have used cat command in unix for joining video, but while played that video file it...
5
by: sonu | last post by:
hey good morning ...... how to convert a video file in .flv format in php for linux hosting......is there any package whis provide this facility . Can i use ffmpeg for linux hosting...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.