using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.IO; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("server=.;database=Sample;integrated security=true"); SqlCommand com = new SqlCommand("insert into tblVoice(fldvoice) values(@voice)", con); byte[] stream = File.ReadAllBytes(@"d:\m.wma"); if (stream.Length > 0) { com.Parameters.AddWithValue("@voice", stream); con.Open(); int result=com.ExecuteNonQuery(); if (result > 0) MessageBox.Show("insert done"); con.Close(); } } private void Form1_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("server=.;database=Sample;integrated security=true"); SqlCommand com = new SqlCommand("select * from tblVoice", con); con.Open(); DataTable dt = new DataTable(); SqlDataReader dr = com.ExecuteReader(); dt.Load(dr); dr.Close(); con.Close(); byte[] stream = (byte[])dt.Rows[0][0]; File.WriteAllBytes("D:\\news.wma", stream); axWindowsMediaPlayer1.URL = "D:\\news.wma"; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)