0

i'm having a problem in retrieving .wav file in ms access in my code in c# it says that the wave header is corrupt! can someone help me with this? thanks :)

cmd = new OleDbCommand("Select SOUND from SOUND where TITLE like" + "'" + textBox1.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read() == true)
                {
                    byte[] result = (byte[])dr["SOUND"];


                    MemoryStream ms = new MemoryStream(result, true);
                    SoundPlayer sp = new SoundPlayer(ms); 
                    ms.Position = 0; 
                    sp.Stream = null;
                    sp.Stream = ms; 
                    sp.Play(); // error here!! :(

                }
                else
                    MessageBox.Show("error");
3
Contributors
3
Replies
6
Views
6 Years
Discussion Span
Last Post by aniperiye
0

The method you are using to play the sound is OK.
The following code works fine for me.

byte[] result = System.IO.File.ReadAllBytes(@"C:\WINDOWS\Media\ding.wav");
            System.IO.MemoryStream ms = new System.IO.MemoryStream(result);
            SoundPlayer sp = new SoundPlayer(ms);
            sp.Play();

Have you checked that there is data in result?
How are you putting the data in to your DB?

0

The method you are using to play the sound is OK.
The following code works fine for me.

byte[] result = System.IO.File.ReadAllBytes(@"C:\WINDOWS\Media\ding.wav");
            System.IO.MemoryStream ms = new System.IO.MemoryStream(result);
            SoundPlayer sp = new SoundPlayer(ms);
            sp.Play();

Have you checked that there is data in result?
How are you putting the data in to your DB?

i insert object in the datasheet view database ms access..ole object..

thanks for replying on my post :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.