Header Ads

uploading images in database.

protected void Button1_Click(object sender, EventArgs e)
{
byte[] image = FileUpload1.FileBytes;

String name = TextBox1.Text;

String qryString = "INSERT INTO [Table] VALUES ( '" + name + "' , '" + image + "' )";
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand command = new SqlCommand(qryString, connection))
{
connection.Open();
command.ExecuteNonQuery();
}
}
}

No comments:

Powered by Blogger.