I have successfully saved an audio file in a MySQL database but I do not know how to get it from the database and Any help to play it will be appreciated.
This is my code for insertion:
private void button 2_Click (object sender, EventArgs e) {try {MySqlConnection connection; String cs = @ "server = 127.0.0.1; userid = root; pwd =; database = atfl fmdb;"; Connection = new MySqlConnection (CS); If (upload text.landa & gt; 0 & amp; amp; amp; vName.Text.Length & gt; 0 & amp; amp; amp; vTel.Text.Length & gt; 0 & amp; amp; tbposition .ext.Length & gt; 0) {string FileName = upload .text; Byte [] f = file. Readlabs (upload text); MySqlCommand selectcom = new MySqlCommand ( "Intrnentrwu (Intonem, Intesposhn, enter Intel, Audiophile) values ( '+ vName.Text +"', ' "+ tbposition.Text +"', ' "+ vTel.Text +"', "+ F +") ", connection); MySqlDataReader myread; connection.Open (); Myread = selectcom.ExecuteReader (); while (myread.Read ()) {} connection.Close (); MessageBox.Show ( "Data saved successfully"); VName.Text = ""; VTel.Text = ""; Tbposition.Text = ""; upload text = "";}} hold (Exception pre) {message box. Show (ex .toString ());}} Private Zero Button 1_Click (Object Sender, Event Arguments e) {{OpenFileDialog openFileDialog1 = New OpenfileDialog ()); OpenFileDialog1.filter = "audio files | *. MP3 "; if (openfileDialog1.ShowDialog () == DialogResult.OK) {upload.Text = openFileDialog1.FileName;}} catch (Exception ex) {message box. Show (ex.Message);}}}}} < / Code>
If you have not resolved, then I just based on the answer given on this link. But this has worked:
At the end of this link it gives you the location of the duplex ZIP package, download and insert the duplexer-swf file in your root folder.
All MS SQL commands MySQL has to be converted to MySQL and MySQL.DLL has to be entered in its bin folder. In my case, I store MP3 files as varbinay and retrieve it using a stored procedure :
private void BindGrid () {string connStr = System.configuration.ConfigurationManager.ConnectionStrings [ "MySqlServer"] ConnectionString. (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient using .MySqlConnection (connStr)) (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand ( "virtual" , Conn)) {Cmd.CommandType = CommandType.StoredProcedure; Conn.Open (); (IDataReader idr = cmd.ExecuteReader ()) using {GridView1.DataSource = idr; GridView1.DataBind (); } Conn.Close (); }}}
More details in this link:
Say audio to you and put it in the original folder. Hope this can help you.
Comments
Post a Comment