using System; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class admin_taastamisleht : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.ReadXml(FileUpload1.FileContent); gridview1.DataSource = ds; gridview1.DataBind(); SqlDataAdapter adapter1 = new SqlDataAdapter(); SqlConnection yhendus = new SqlConnection( ConfigurationManager.ConnectionStrings["yhendus1"]. ConnectionString ); adapter1.InsertCommand = new SqlCommand( "INSERT INTO ajaveebitabel (pealkiri, teatesisu, tyybiID) "+ "VALUES (@pealkiri, @teatesisu, @tyybiID)", yhendus ); SqlParameterCollection parameetrid = adapter1.InsertCommand.Parameters; parameetrid.Add("@pealkiri", SqlDbType.NVarChar, 50, "pealkiri"); parameetrid.Add("@teatesisu", SqlDbType.NText, Int32.MaxValue, "teatesisu"); parameetrid.Add("@tyybiID", SqlDbType.Int, 4, "tyybiID"); adapter1.Update(ds, "rida"); } protected void kustutusnupp_Click(object sender, EventArgs e) { if (kustutaminelubatud.Checked) { SqlConnection yhendus = new SqlConnection( ConfigurationManager.ConnectionStrings["yhendus1"]. ConnectionString ); SqlCommand kask = new SqlCommand("DELETE FROM ajaveebitabel", yhendus); yhendus.Open(); kask.ExecuteNonQuery(); yhendus.Close(); } } }