Retaining original table names during db to xml

  • I am not sure whether this is a proper place to ask this question, but hoping someone might know:

    I read a database into a DATASET in C#.  I then output it as an XML file.  In the XML file, the tables (which initially resided in my db) are called Table, Table1, Table2 ... respectively.

    As such, when I query the XML file (i.e. the tables), I have to use these labels.  Would anyone know how I can retain the orignal table names when the XML file is created from the Dataset?

    Thank you very much

  • You can apply a tablemapping on your data adapter (I assume you have tables with real name MyTable1Name and MyTable2Name: put your names here)

    da is your data adapter

    da.TableMappings.Add("Table", "MyTable1Name");

    da.TableMappings.Add("Table1", "MyTable2Name");

    Then do your fill.

    Russel Loski, MCSE Business Intelligence, Data Platform

  • use ds.readXml then,

    isn't there a ds.Tables(0).tableName or something?


    Ronald San Juan | SQL DBA
    ID 710124 ~ Code "Northwind"

  • Sorry, after rereading your post, I realized I misunderstood you. Here you go...

    da.Fill(ds, "YourTableName);

    da2.Fill(ds, "YourNextTableName);

    ds.SaveXML("path");


    Ronald San Juan | SQL DBA
    ID 710124 ~ Code "Northwind"

  • Guys,

    Thanks for all the help.

    I solved the problem by using what was stated in one of the postings above.  Namely,

    Dataset.Tables[0].TableName = "Real Name"

  • Merry Christmas!    ß Click Here


    Ronald San Juan | SQL DBA
    ID 710124 ~ Code "Northwind"

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply