Hi

I understand that a dataadaptor can have multiple tablemappings, but how can
I get the schemas and or xml data of multiple tables to be written to the
same file, in one action, but have it so each table is separated in its own
block?

The below code shows 2 tables, but the select statement only retreives all
rows from one of the tables. Need some way select all from both tables but
when written to xml, they are separate tables?

OdbcDataAdapter myAdapter = new OdbcDataAdapter();
myAdapter.TableMappings.Add("Address", "DataAddress");
myAdapter.TableMappings.Add("Products", "DataProducts");
//myConnection.Open();
OdbcCommand myCommand = new OdbcCommand("SELECT * FROM \"Address\"",
myConnection);
myCommand.CommandType = CommandType.Text;
myAdapter.SelectCommand = myCommand;
DataSet ds = new DataSet("AllData");
myAdapter.Fill(ds);
ds.WriteXml("d:\\AllData.XML", XmlWriteMode.WriteSchema);

Thanks in Advance

David

Solution - Table Mappings and Multiple Tables to XML by David

David
Fri Feb 20 07:10:52 CST 2004

Here is the solution to the problem. From the line myAdapter.Fill(ds);
replace with the below

myAdapter.Fill(ds,"Address");
OdbcCommand myCommand2 = new OdbcCommand("SELECT * FROM \"Products\"",
myConnection);
myCommand2.CommandType = CommandType.Text;
myAdapter.SelectCommand = myCommand2;
myAdapter.Fill(ds, "Products");

"David W" <david@nospam.net> wrote in message
news:uk8HDB79DHA.2804@TK2MSFTNGP09.phx.gbl...
> Hi
>
> I understand that a dataadaptor can have multiple tablemappings, but how
can
> I get the schemas and or xml data of multiple tables to be written to the
> same file, in one action, but have it so each table is separated in its
own
> block?
>
> The below code shows 2 tables, but the select statement only retreives all
> rows from one of the tables. Need some way select all from both tables but
> when written to xml, they are separate tables?
>
> OdbcDataAdapter myAdapter = new OdbcDataAdapter();
> myAdapter.TableMappings.Add("Address", "DataAddress");
> myAdapter.TableMappings.Add("Products", "DataProducts");
> //myConnection.Open();
> OdbcCommand myCommand = new OdbcCommand("SELECT * FROM \"Address\"",
> myConnection);
> myCommand.CommandType = CommandType.Text;
> myAdapter.SelectCommand = myCommand;
> DataSet ds = new DataSet("AllData");
> myAdapter.Fill(ds);
> ds.WriteXml("d:\\AllData.XML", XmlWriteMode.WriteSchema);
>
> Thanks in Advance
>
> David
>
>