int i=0; byte[] img_bt=null; FileStream fs=new FileStream(this.textBox4.Text,FileMode.Open,FileAccess.Read); BinaryReader br=new BinaryReader(fs); img_bt=br.ReadBytes((int)fs.Length); SqlCommand cmd = new SqlCommand("insert into prac_imag values(@sno,@name,@city,@image", con); cmd.Parameters.AddWithValue("@sno", Convert.ToInt32(textBox1.Text)); cmd.Parameters.AddWithValue("@name", textBox3.Text); cmd.Parameters.AddWithValue("@city", textBox2.Text); cmd.Parameters.AddWithValue("@image",img_bt); con.Open(); i = cmd.ExecuteNonQuery(); if (i > 0) { MessageBox.Show("Data has been saved"); } else { MessageBox.Show("Data has not been saved"); } con.Close();
SqlParameter image = new SqlParameter("@image", SqlDbType.VarBinary, img_bt.Length); image.Value = img_bt; cmd.Parameters.Add(image);
cmd.Parameters.AddWithValue("@image", img_bt, SqlDbType.VarBinary)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)