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 taasta : System.Web.UI.Page { protected void Having_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("TRUNCATE TABLE inimesed", new SqlConnection(ConfigurationManager.ConnectionStrings["baas1ConnectionString2"].ConnectionString)); cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.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 inimesed (eesnimi, synniaasta) VALUES (@enimi, @synnia)", new SqlConnection(ConfigurationManager.ConnectionStrings["baas1ConnectionString2"].ConnectionString)); daUpdate.InsertCommand.Parameters.Add("@enimi", SqlDbType.NVarChar, 50, "eesnimi"); daUpdate.InsertCommand.Parameters.Add("@synnia", SqlDbType.Int, 4, "synniaasta"); daUpdate.Update(ds, "inimesed"); /* daUpdate.InsertCommand = new SqlCommand("dbo.TaastaInimene", new SqlConnection(ConfigurationManager.ConnectionStrings["baas1ConnectionString2"].ConnectionString)); daUpdate.InsertCommand.CommandType = CommandType.StoredProcedure; daUpdate.InsertCommand.Parameters.Add("@id", SqlDbType.Int, 4, "id"); daUpdate.InsertCommand.Parameters.Add("@enimi", SqlDbType.NVarChar, 50, "eesnimi"); daUpdate.InsertCommand.Parameters.Add("@synniaasta", SqlDbType.Int, 4, "synniaasta"); daUpdate.Update(ds, "inimesed"); */ } } }