By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,795 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,795 IT Pros & Developers. It's quick & easy.

Need reference for storing/retrieving .wav files in Sql2000

P: n/a
I can successfully write the binary data to an image data type, and
successfully retrieve it, but when I attempt to play the file in media player
after retrieving it, I get the file type isn't supported.

I must be losing something somewhere, but the byte lengths match up. Is
there some encoding I need to do.

Please take a look, and suggestions would be appreciated.
//Writing to sql from file

FileStream fs = new FileStream("xxx.wav", FileMode.Open, FileAccess.Read);

BinaryReader br = new BinaryReader(fs);
long size = fs.Length;

byte[] data = new byte[size];

br.Read(data,0,data.Length);

Database db = DatabaseFactory.CreateDatabase("IvrRecordingDB");

DBCommandWrapper cmd = db.GetStoredProcCommandWrapper("uspInsertRecording ");

cmd.AddInParameter("@recording", DbType.Binary, data);

db.ExecuteNonQuery(cmd);

//Retrieving data and writing to file
byte[] data = new byte[0];

Database db = DatabaseFactory.CreateDatabase("IvrRecordingDB");
DBCommandWrapper cmd = db.GetStoredProcCommandWrapper("uspGetRecording");

object audioBinary = db.ExecuteScalar(cmd);
data = (byte[])(audioBinary);

FileStream fs = new FileStream("new.wav",FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);

bw.Write(data,0,data.Length);
bw.Close();
fs.Close();

Jan 13 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.