toanhoi bui

toanhoi bui

  • NA
  • 70
  • 169.7k

Error load audio from sql to Datagridview

Apr 1 2011 9:11 AM
I using C# to write a project to load file audio which formats .wav from SQL to DataGridView. But it was error .Can you help me,please ?

SqlConnection con = new SqlConnection("Data Source=CHANGEME1;AttachDbFilename=D:\\Code C#\\SimpleRec\\DataBase_Audio
  SqlCommand com = new SqlCommand("select *  from tbAudio where MaThe =136020379226", con);
  con.Open();
  DataTable dt = new DataTable();
  SqlDataReader dr = com.ExecuteReader();
  dt.Load(dr);
  if (dt.Rows.Count == 1)
  {
  dataGridView1.DataSource = dt;
  }
  dr.Close();
  con.Close();
  byte[] stream = (byte[])dt.Rows[0][0];

 
  File.WriteAllBytes("D:\\news.wma", stream);

Error is "The following exception occurred in the DataGridview"

Answers (2)