0

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...:$

6
Contributors
5
Replies
27
Views
7 Years
Discussion Span
Last Post by JobPencil
0

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");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.