hi,
Please show me how to write data from a table in a database to xml and loading or inserting xml data to database(reverse process).
I don't have any idea of this problems.
I have Tried my level best,but failed to do so..
please show me how to copy data from 1 database to another databse ..
Anyone please Help me:'(
Anyway ThAnkS in Advance...:$

Use DataSet class,

// Populate DataSet using Database
    SqlDataAdapter adp = new SqlDataAdapter("select * from tableName", "your_conn_str");
     DataSet ds=new DataSet("MyDB");
     adp.Fill(ds,"tableName");
 
     // Write Data into XML
        ds.WriteXml("file.xml");
// Load(Read) XML data

          DataSet ds=new DataSet();
          ds.ReadXml("file.xml");
          DataTable dt=ds.Tables["tableName"];
          dt.Rows.Add("val1","val2"); // Adding row
// Update database
           SqlDataAdapter adp=new SqlDataAdapter("select * from tableName","your_conn_str");
           SqlCommandBuilder cb = new SqlCommandBuilder(adp);
           DataSet ds = new DataSet();
           ds.ReadXml("file.xml");
           DataTable dt = ds.Tables["tableName"];
           dt.Rows.Add("val1", "val2"); // Adding row
           adp.Update(ds, "tableName");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.