Consume Web API in ASPX Page using C# in ASP.Net

Last Reply on Feb 09, 2018 02:17 AM By dharmendr

Posted on Feb 08, 2018 11:14 PM

hello,

this code for select data from sql covert to xml and download works great.

now i am looking for the same way for insert and update methods so user can xml file in their directory and run insert and update using xml and xml file send the insert and update to database sql server please advice

protected void GenerateXML(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString);
    SqlDataAdapter dt = new SqlDataAdapter("SELECT * FROM Customers", con);
    DataSet ds = new DataSet();
    dt.Fill(ds, "Customers");
    ds.WriteXml(Server.MapPath("~/Customers.xml"));
}
 
protected void DownloadXML(object sender, EventArgs e)
{
    if (System.IO.File.Exists(Server.MapPath("~/Customers.xml")))
    {
        DownloadFile(Server.MapPath("~/Customers.xml"));
    }
}

I want an API which can take value of texbox and save in to sql server database.

Posted on Feb 09, 2018 02:17 AM