using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Sql; using System.Data.SqlClient; using System.Configuration; public partial class pildileht2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection( ConfigurationManager.ConnectionStrings[ "ConnectionString"].ConnectionString); SqlCommand cm = new SqlCommand("INSERT INTO tegelased " + "(eesnimi, pildiandmed) VALUES (@eesnimi, @pilt)", cn); cn.Open(); byte[] baidid=new byte[FileUpload1.PostedFile.ContentLength]; FileUpload1.PostedFile.InputStream.Read(baidid, 0, baidid.Length); cm.Parameters.AddWithValue("eesnimi", TextBox1.Text); cm.Parameters.AddWithValue("pilt", baidid); cm.ExecuteNonQuery(); } }