.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Audio Song Uploading

Posted By:Dinkar       Posted Date: April 19, 2011    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

In this Article we see how to upload Audio or MP3 song in Database and also Aplication folder like Audio.This is simple code useful for Developer
 

In this Article we see how to upload Audio or MP3 song in Database and also Aplication folder like Audio.This is simple code useful for Developer
So lets see  step by step procedure


Step 1) Take textbox and fileupload control and Button 


Step 2) Create table like

CREATE TABLE [dbo].[Audio](
  [id] [int] NOT NULL,
  [song] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Audio] PRIMARY KEY CLUSTERED 
)


Step 3)Now write stored procedure

ALTER procedure Sp_Audio(@id int,@song varchar(50))
As
Begin
insert into Audio(id,song)values(@id,@song)
end
}
 
Step 4) Now double click on Button and write code

{
SqlConnection cn = new SqlConnection("Give Path");
 
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = cn;
  cn.Open();
  cmd.CommandText = "Sp_Audio";
  cmd.CommandType = CommandType.StoredProcedure;
 
  cmd.Parameters.AddWithValue("@id", TextBox1.Text);
  cmd.Parameters.AddWithValue("@song", FileUpload1.FileName);
  int i=cmd.ExecuteNonQuery();
 
  if (FileUpload1.HasFile)
  {
  string fname = FileUpload1.FileName.ToString();
  string folderpath = "~/Audio";
  string path = HttpContext.Current.Server.MapPath(folderpath);
 
  FileUpload1.PostedFile.SaveAs(path + "\\" + fname);
  Label1.Text = "file uploaded successfully";
  }
  }
}

Step 5) Now Run Application


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend