using System; using System.Data; 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; using System.Data.Sql; using System.Data.SqlClient; public partial class Admin_taasta : System.Web.UI.Page { protected void bKustuta_Click(object sender, EventArgs e) { SqlConnection toru = new SqlConnection( ConfigurationManager .ConnectionStrings["baas1ConnectionString"] .ConnectionString); SqlCommand kask = new SqlCommand( "DELETE dbo.ajaveeb "); kask.Connection = toru; toru.Open(); kask.ExecuteNonQuery(); toru.Close(); } protected void bTaasta_Click(object sender, EventArgs e) { if (fuXML.HasFile) { DataSet ds = new DataSet(); ds.ReadXml(fuXML.FileContent); GridView1.DataSource = ds; GridView1.DataBind(); SqlDataAdapter daUpdate = new SqlDataAdapter(); daUpdate.InsertCommand = new SqlCommand( "INSERT INTO ajaveeb (pealkiri, teade, aeg)" + "VALUES(@pealkiri, @teade, @aeg)"); daUpdate.InsertCommand.Connection = new SqlConnection(ConfigurationManager .ConnectionStrings["baas1ConnectionString"] .ConnectionString); daUpdate.InsertCommand.Parameters.Add ("@pealkiri", SqlDbType.NVarChar,50,"pealkiri"); daUpdate.InsertCommand.Parameters.Add ("@teade", SqlDbType.NText, Int32.MaxValue , "teade"); daUpdate.InsertCommand.Parameters.Add ("@aeg", SqlDbType.DateTime,8,"aeg"); daUpdate.Update(ds, "rida"); } } }