I have uploaded audio files (saved them) into the SQL Server 2005 database.
I need to prepare a "play sound" button to allow users to click it and listen to the sound.
I have the following code to retrieve the audio file from the database.
protected void playsound_btn_Click(object sender, ImageClickEventArgs e)
{
Label Sound_nameLabel = (Label)QuestionsFormView.FindControl("Sound_nameLabel");
string soundName = Sound_nameLabel.Text;
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["preschoolkidsConnectionString"].ConnectionString);
connection.Open();
SqlCommand dCmd = new SqlCommand("SelectAudioBySoundName", connection);
dCmd.CommandType = CommandType.StoredProcedure;
try
{
SqlParameter param = new SqlParameter("@Sound_name", SqlDbType.VarChar, 50);
param.Value = soundName;
dCmd.Parameters.Add(param);
DataTable dt = new DataTable();
SqlDataReader dr = dCmd.ExecuteReader();
dt.Load(dr);
byte[] stream = (byte[])dt.Rows[0][0];
}
catch
{
throw;
}
finally
{
dCmd.Dispose();
connection.Close();
connection.Dispose();
}
}
But I could not find a way to to code it so that can play it on user click.
Please help me...thank you.
p/s: im doing web application.