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();