Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

I am creating a database that has a table with a field which contains mp3 files.

I am creating a program using C# that when the user clicks on a button , it opens the mp3 file.

So what datatype should I store the mp3 file as?

I cannot find "BLOB" datatype in sql server 2008 version...

so whats the alternative?

thanks
Posted
Comments
CHill60 10-Jul-14 7:16am    
Your post body and title don't match - are you trying to store the mp3 files themselves or a weblink to them?
xirokx 10-Jul-14 7:47am    
whats best practice?

to store the mp3 file itself? or to save a weblink that retrieves it?

thanks

You can use VarBinary(max) tom store files like audio, video, images...

But you have to convert your fils to bytes before sending it to database
 
Share this answer
 
Further to solution 2

There is an image datatype in SQL 2008 that you might come across - don't be tempted to use it - see why here[^]. VarBinary(MAX) is the better solution.

You might also find this article useful Storing Images and BLOB files in sql server[^] - it targets earlier versions of sql server but also links to storing of blobs using FILESTREAM in SQL 2008.

If however, you are just intending to store a link to the file on your database then use nvarchar
 
Share this answer
 
Comments
xirokx 10-Jul-14 7:46am    
thanks for recommendations....

well whats the best way to store them?

my c# program allows user to click on the link and the mp3 opens up and streams and plays.

is it better for me to store the mp3 in my database?

or can i store them elsewhere (somehow???) and generate a weblink that I can store inside sql server field that retrieves them?

please kindly help

thanks
xirokx 10-Jul-14 16:55pm    
anyone?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900