Hi Evry one, I am trying to code a web application for videos and musics, I got stack on trying to upload Video’s path in the database and the system is not giving any error but the browser is just freezing. I can easily upload songs and pictures but the other major problem is with songs paths they’r no playing when I bind them to the repeater. Bellow is my project sample codes:Table, Stored Procedures, NewSoundClass, Main codes and Source code. I am using TableAdapter.
If any one can help please, I'll really appreciate it ..pls,pls
Help also with the codes for downloading music and videos.
Table TBSound
Col_Name Data_Type AllowNull
SoundId int Unchecked
SoundName nvarchar(50) Checked
Soundstream nvarchar(MAX) Checked
I have two store procedures:
1. ALTER PROCEDURE dbo.SaveM
(
@SoundName nvarchar(50),
@Soundstream nvarchar(MAX)
)
AS
SET NOCOUNT OFF;
INSERT INTO [dbo].[TBSound] ([SoundName], [Soundstream]) VALUES (@SoundName, @Soundstream);
- SELECT SoundId, SoundName, Soundstream FROM TBSound WHERE (SoundId = SCOPE_IDENTITY())
2. ALTER PROCEDURE dbo.SelectQuerySound
(
@SoundId int
)
AS
SET NOCOUNT ON;
SELECT Soundstream
FROM TBSound
1. WHERE (SoundId = @SoundId)
Here bellow is my class where I call my stored procedures using TableAdapter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class NewSound
{
SoundDataSet1TableAdapters.TBSoundTableAdapter MyVid = new SoundDataSet1TableAdapters.TBSoundTableAdapter();
public NewSound()
{
}
public bool SaveMed(string SoundName, string SoundStream)
{
int MySound = MyVid.SaveM(SoundName, SoundStream);
return MySound == 1;
}
public SoundDataSet1.TBSoundDataTable SearchM(int SoundId)
{
return MyVid.GetDataBySound(SoundId);
}
}
My Main Codes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
NewSound VidSound = new NewSound();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSaveUpload_Click(object sender, EventArgs e)
{
string FileName = Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("Videos/" + FileName));
VidSound.SaveMed(TextBox1.Text,FileName);
}
protected void btnRepeater_Click(object sender, EventArgs e)
{
RepeatData.DataSource = VidSound.SearchM(Convert.ToInt32(TextBox1.Text));
RepeatData.DataBind();
}
}
Source Codes
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td>
</td>
<td class="style2" colspan="3">
Inserting Sound And Video in the Database</td>
<tr>
<<br mode="hold" /> <td class="style3">
<asp:TextBox ID="TextBox1" runat="server">
</td>
<td colspan="2">
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
<td>
</td>
<td class="style3">
<asp:Label ID="Label1" runat="server" Text="Label">
</td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
Text="Repeater" />
<td>
<asp:Repeater ID="RepeatData" runat="server">
<itemtemplate>
<object id="player"
classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"
height="170" width="300">
<param name="url">
value='<%# "VideoHandler.ashx?id=" + Eval("SoundId") %>'/>
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
</object>
</param></itemtemplate>
</td></td></tr>
</tr></table>
</div>
</form>
</body>
</html>
the idea is to have by the end a gridview that look like this:
Sound Id Sound Name View/Listen Get it
01 Single Lady Play Download