using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; public partial class xmlproov_taastamine : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (varundusfail.HasFile) { Label1.Text = "Fail olemas pikkusega " + varundusfail.FileBytes.Count().ToString(); DataSet ds = new DataSet(); ds.ReadXml(varundusfail.FileContent); GridView1.DataSource = ds; GridView1.DataBind(); SqlDataAdapter adapter = new SqlDataAdapter(); SqlConnection cn = new SqlConnection(ConfigurationManager. ConnectionStrings["korvpallConnectionString1"].ConnectionString); SqlCommand cm = new SqlCommand("DELETE FROM uudised", cn); cn.Open(); cm.ExecuteNonQuery(); adapter.InsertCommand=new SqlCommand( "INSERT INTO uudised(pealkiri, uudis, aegumisaeg, aktiivne ) "+ "VALUES(@p, @u, @aeg, @akt)", cn); SqlParameterCollection pm = adapter.InsertCommand.Parameters; pm.Add("p", SqlDbType.NVarChar, 50, "pealkiri"); pm.Add("u", SqlDbType.NVarChar, 255, "uudis"); pm.Add("aeg", SqlDbType.DateTime, 8, "aegumisaeg"); pm.Add("akt", SqlDbType.Int, 1, "aktiivne"); adapter.Update(ds.Tables[0]); Label1.Text = "andmed kohal"; } else { Label1.Text = "Fail puudub"; } } }