1

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

2 Answers 2

2

If "Uploads" is the name of the table, then:

sourcedata = ds.Tables["Uploads"];
Sign up to request clarification or add additional context in comments.

5 Comments

in the WriteToServer line, am I supposed to put in the name of the dataset created from the xml Ive read in? (hope that makes sense...)
@Pedro not sure if that is a question...?
What I meant was, the xml reads in, I have the column mappings done ok, but at this last step WriteToServer([something]), I know [something] should be what it is Im writing, but through trial and error I cant quite get what should be in here.
@Pedro what happens when you use the table name? Or just Tables[0]
Just kinda times out and gives me a 'page cannot be displayed' error, but what you've said has put me on the right path now so thanks for that - think I just have a couple if things the wrong way round.
1

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"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.