Reputation: 2851
I posted earlier (and received valid answers, thanks) about a problem I had loading xml into sql. Ive got the code working to a point, but just not sure how to define what table to load the data to.
How can I find out the zero-based index of the table if I use the line below
sourcedata = ds.Tables[0];
Or, if I use
sourcedata = ds.Tables[Uploads];
how should this be formatted, as I get an error due to a type being used like a variable
thanks again
Upvotes: 1
Views: 280
Reputation:
You can get table based on name of table. your table name will be same as your xml tag name. for example if your xml is like below :
<root>
<customer>
<name>test</name>
<age>20</age>
<customer>
</root>
You need to access table using :
DataTable customerTable = dsData.Tables["Customer"]
Upvotes: 1
Reputation: 1062600
If "Uploads" is the name of the table, then:
sourcedata = ds.Tables["Uploads"];
Upvotes: 2