Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Someone sends me an xml file in a set format. I want to take that and get all of the records into a blank SQL Server table. I can build the table first because I know the fields.

What is the fastest way to get this accomplished in C#?

Wanna-Be C# Superstar
Posted

Haven't had much luck getting responses there and this seems like something that is trivial and can easily be accomplished in .NET.

Yet after an hour of Googling I have only come up with SQL stored procedures to get it done.

I'm not really sure what defines a 'General' question and I didn't realize these forums were so well policed. I'll try not to step out of line again.

Wanna-Be C# Superstar
Posted
Incidentally, the term xml cannot be used to search these forums. I realize that small words like 'the' and 'and' don't contribute much to a search query but isn't something like 'xml' distinctive enough that users could be allowed to search on it? Much like a search for 'awk' or 'rpc'.
Wanna-Be C# Superstar
  • Administrators
Posted
Could you not load the xml into a typed dataset and use that to update the database? Alternatively you could load the file into a XmlDocument and loop over it's contents, or even use a XmlReader to read through the file and update the db manually

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

What I wound up doing was just that. I looped over the xml and manually created an insert statement to put the records in. It's not pretty. I'm testing with 5 records. Go time will be 500,000 records.

 

The dataset.update method is, from my exploration, something that recognizes changes that you have made to a dataset since you call a Fill on it. I'm filling it from the xml and not making any changes, so MS has over-engineered that bit for me.

Wanna-Be C# Superstar

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...