Friday, February 24, 2012

How to store .wav or .mp3 file in SQL Server 2000

Hi,

I have a problem to store .wav and .mp3 file to store in SQL Server
2000.

How can I store this?

Can any one give me code regarding this. I have little bit idea. But
I need some technical help in Code.

Thanks in advance,

PratikHere's some code to get you started:

CREATE TABLE MyMp3s
(
Mp3Image image
)
GO

CREATE PROC InsertMp3Image
@.Mp3Image image
AS
INSERT INTO MyMp3s VALUES(@.Mp3Image)
GO

// C# code snippet

Int32 m_MaxFileSize = 10240000;

SqlCommand storedProcedure =
new SqlCommand("InsertMp3Image" , SqlConnection);
storedProcedure.CommandTimeout = 30;
storedProcedure.CommandType = CommandType.StoredProcedure;

System.IO.BinaryReader binaryReader =
new BinaryReader(
new FileStream (@."C:\Mp3\MyMp3.mp3",
FileMode.Open,
FileAccess.Read));

byte[] buffer = binaryReader.ReadBytes(m_MaxFileSize);

binaryReader.Close();

storedProcedure.Parameters.Add( "@.Mp3Image", buffer );

storedProcedure.ExecuteNonQuery();

--
Hope this helps.

Dan Guzman
SQL Server MVP

--------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index...epartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--------

"Pratik Kothari" <pratik.kothari@.dadomain.com> wrote in message
news:d025254b.0311210330.1fcb8ef3@.posting.google.c om...
> Hi,
> I have a problem to store .wav and .mp3 file to store in SQL Server
> 2000.
> How can I store this?
> Can any one give me code regarding this. I have little bit idea. But
> I need some technical help in Code.
> Thanks in advance,
> Pratik|||pratik.kothari@.dadomain.com (Pratik Kothari) wrote in message news:<d025254b.0311210330.1fcb8ef3@.posting.google.com>...
> Hi,
> I have a problem to store .wav and .mp3 file to store in SQL Server
> 2000.
> How can I store this?
> Can any one give me code regarding this. I have little bit idea. But
> I need some technical help in Code.
> Thanks in advance,
> Pratik

You sure you want to? Why not store the file on the hard drive and
name of the file in the database?|||>>>>>
You sure you want to? Why not store the file on the hard drive and
name of the file in the database?
<<<<<

While this approach is much easier to implement, there is a host of
security and data integrity issues that vitiates its use.

1) What if someone deletes the file? You end up with a dangling
reference.

2) What if someone, innocently or otherwise, overwrites the file? Bad
voodoo.

HTH

=======================================
Everyone here speaks SQL; some are more fluent, others less. When
describing your SQL object (table, etc.), do so in the language that we
all understand - SQL, not English. It makes it easier to understand
your issue and makes it more likely that you will get the assistance
that you are asking for.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Thanx Dan,

This is that what i want.

Pratik

No comments:

Post a Comment