using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.Sql; using System.Data.SqlClient; using System.Data.SqlTypes; public partial class taastamine : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { DataSet ds1 = new DataSet(); ds1.ReadXml(FileUpload1.FileContent); //GridView1.DataSource = ds1; //GridView1.DataBind(); SqlDataAdapter adapter1 = new SqlDataAdapter(); SqlConnection cn=new SqlConnection(ConfigurationManager. ConnectionStrings["kursusebaasConnectionString1"].ConnectionString); //Kustutame olemasolevad kirjed juhul kui linnuke on märgitud if (CheckBox1.Checked) { SqlCommand cm = new SqlCommand("DELETE FROM teated", cn); cn.Open(); cm.ExecuteNonQuery(); } //lisame failist tulevad andmed adapter1.InsertCommand = new SqlCommand( "INSERT INTO teated (aeg, pealkiri, jutt) " + "VALUES(@a, @p, @j)", cn); SqlParameterCollection pm = adapter1.InsertCommand.Parameters; pm.Add("a", SqlDbType.DateTime, 8, "aeg"); pm.Add("p", SqlDbType.NVarChar, 50, "pealkiri"); pm.Add("j", SqlDbType.NVarChar, 200, "jutt"); adapter1.Update(ds1.Tables[0]); Button1.Text = "Andmed salvestatud"; } } }