I am looking to insert both image and audio into sql with this code , how can I make this binary reader to read multiple files ? audio and image ?
protected void Button1_Click1(object sender, EventArgs e)
{
using (BinaryReader br = new BinaryReader(FileUpload1.PostedFile.InputStream))
{
byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length);
string strConnString = ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "INSERT INTO tblComplaint(customerName, type, status,reply,Date,image) VALUES (@customerName, @type, @status,@reply,@Date,@audio)";
cmd.Parameters.AddWithValue("@customerName", TextBox1.Text);
cmd.Parameters.AddWithValue("@type", TextBox2.Text);
cmd.Parameters.AddWithValue("@status", TextBox3.Text);
cmd.Parameters.AddWithValue("@reply", TextBox4.Text);
cmd.Parameters.AddWithValue("@date", TextBox5.Text);
cmd.Parameters.AddWithValue("@audio", bytes);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Response.Redirect(Request.Url.AbsoluteUri);