-1

I want to upload a mp3 and store song details in audio table and save that song to a folder. and when user click the play button then pass that song url to windows media player to play the song...

i has created a table like:

Column             Datatype         Allownulls

s_ID (primary)      int                 no

Songurl            Varchar(MAX)        yes

song name          Varchar(50)         yes

i am using MS visual studio 2008 and sql server 2005.

plz suggest me idea and example of code to how to create... Advace thank you...

Bastardo
  • 4,144
  • 9
  • 41
  • 60
Abhishek Nayak
  • 3,732
  • 3
  • 33
  • 64

4 Answers4

1

You mean the corresponding C# class per your question? Surely just strings, no?

class Song
{
    public int Id {get; set; }
    public string Url {get; set; }
    public string Name {get; set; }
}
tomfanning
  • 9,552
  • 4
  • 50
  • 78
1

The songurl and songname should both be NVARCHAR(MAX) (instead of MAX 500 chars should be sufficient for both) to allow non-ASCII characters.

As Vamsi Krishna noted, a URL should not be longer than 2000 characters, so thats the upper bound for this field.

The create table statement would be

CREATE TABLE songs (
  id INT,
  song_url NVARCHAR(2000),
  song_name NVARCHAR(MAX)
);

On the C# side, string is the right datatype. Maybe URI for the song_url as suggested by Firedragon.

Matten
  • 17,365
  • 2
  • 42
  • 64
  • 1
    Please check [Maximum length of Url](http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url), +1 For the answer – Vamsi Dec 09 '11 at 09:50
  • 1
    2000 character (or 2083 to be exact) are a lot more than I've ever seen, but Firefox accepting URLs up to 65000 is hilarious. We use 500 characters in the most cases in our company and have never run into a `string would be truncated` exception. – Matten Dec 09 '11 at 09:55
  • 1
    yeah! I agree, but i guess the application must be ready for the worst situation, even if it never occurs – Vamsi Dec 09 '11 at 10:10
  • 1
    Or the application should handle truncation if it needs to occur - you really don't want to set columns to be massively longer than they typically need to be. – Fenton Dec 09 '11 at 10:37
  • @Sohnee this depends on the application you develop. If you know how many rows will be inserted and that it is only available to a small circle of users, you'd probably have the columns larger or MAX sizes and don't implement truncation logic. But if it is open to a large amount of users, some fine tuning is necessary :) – Matten Dec 09 '11 at 11:27
0

The same as you would use when using Ruby and make a command line app, or when you woud make a local windows application - this is so totally unrelated to asp.net that you rather take a good book.

Varchar(x) with x not being max but a sensible length. 256 comes to my mind. Now, song name as varchar(50) makes no sense either - this is QUITE short. QUITE as in - I am sure there is a song with more than 50 chars. The song name may also be better as nvarhar unicode because you can assume it has not always only english characters but also langauge specific items.

TomTom
  • 61,059
  • 10
  • 88
  • 148
0

There is a Uri class that might be what you are looking for:

http://msdn.microsoft.com/en-us/library/system.uri%28v=vs.71%29.aspx

Makes it easier to manipulate than strings.

Firedragon
  • 3,685
  • 3
  • 35
  • 75