What is the quickest way to get an xml based dataset to add entries to SQL Server?

Because there is no 'datareader' involved, what is the most efficient
way to get an XML based dataset to be added to an SQL server dataset? I
would hate to have to create a new SQL connection and iterate through
making "executenonquery" for each row in the dataset. That seems
horribly in-efficient. I know of no other way to get an xml based
dataset to push data to the database though. Any pointers?

Thanks for any pointers,
Peter Robbins
Freelance Programmer C#/PHP

0
murdock1 (3)
7/26/2006 1:54:18 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
908 Views

Similar Articles

[PageSpeed] 35

"MurdockSE" <murdock@nc.rr.com> wrote in message 
news:1153922058.675709.165630@h48g2000cwc.googlegroups.com...
> Because there is no 'datareader' involved, what is the most efficient
> way to get an XML based dataset to be added to an SQL server dataset? I
> would hate to have to create a new SQL connection and iterate through
> making "executenonquery" for each row in the dataset. That seems
> horribly in-efficient. I know of no other way to get an xml based
> dataset to push data to the database though. Any pointers?

Use a DataAdapter and do an Update. Just make sure all the rows youi want 
added are marked as being in Add state.

John


0
John
7/26/2006 4:15:38 PM
Excuse my ADO.NET naivite (newbie alert*) but how do I iterate the
existing ds and set all of the rows to ADD?

For example:

DataSet ds = new DataSet("MyRecords");
ds.ReadXml(xmlfilename);

And the seperate SQL creations would be similar to this:

using System.Data.SqlClient;
using System.Data;

string strDBConnection = "server=(local);database=DatabaseName;user
id=UserName;password=Pwd;connection reset=false;connection
lifetime=5;Trusted_Connection=Yes;"
SqlConnection dbConnection;
dbConnection = new SqlConnection(strDBConnection);

string strSelectSql = "Select * from
[DatabaseName].[OwnerName].[TableName] order by FieldName";

//Open the connection
dbConnection.Open();

//Create a command
SqlCommand selectSqlCommand = new
SqlCommand(strSelectSql,dbConnection);
SqlDataAdapter sqlData = new SqlDataAdapter(selectSqlCommand);
DataSet dsSelectData = new DataSet();
sqlData.Fill(dsSelectData);

How do I get the ds into the sqlData adapter set to ADD each row?


Peter Robbins

0
murdock1 (3)
7/26/2006 5:06:50 PM
I got the answer/s I was looking for here:

http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/browse_frm/thread/ffc82ed6e1b67fe7/54cdbb1ef9226fef?hl=en&

Thanks again. You basically stated the same thing. My naive self just
needed a little extra push on the particulars. Thanks.

Peter Robbins

0
murdock1 (3)
7/26/2006 8:12:28 PM
Reply:

Similar Artilces:

Is there any replacement for SQLXML in sql server 2008 R2?
Hi, Is there any replacement for SQLXML in sql server 2008 R2? I have to produce XML export files based on my database data every night. The XML structure has nested tags and is complex. What would be the best tool to do this? I am aware of FORXML clause and I am hoping to have a better option. Thank you, Max ...

How to Create a Discount Calculator based on volume
I am trying to create a cost calculator form, which will automatically calculate the discounted monthly price for a service based on the number of units. I want to have a single cell which will calculate the discount rate based on the number of units. The discounts are: if units =<50 price = 10 if units =>51 and <101 price = 9.75 if units =>101 and <201 price = 8.75 if units =>201 and <301 price = 8.00 if units =>301 and <401 price = 7.00 if units =>501 and <501 price = 6.00 if units =>501 price = 5.00 I have tried to create a module in VBA,...

how do I get access privileges in a publisher file. I can't save . #2
After switching from Office XP to Office 2003, I get the following message when trying to save my publisher files: The file%s cannot be opened. Access privileges have not been given. How do I solve this? It's my own file. Hi, No. I don't have a network. And as for the virus scanner: I have Symantec antivirus corporate edition, not Norton, so no possibility to disable office plug-in. Furthermore; this is the only file doing this. Other files are not affected. Ellen "JoAnn Paules - MVP Publisher" wrote: > Is this on a networked system? > > JoAnn Paules > MV...

What happened that I get "-" in a cell
I have simple Sum Functions in my Worksheet and they are all correct. In one of the Cells I only get a minus "-" sign. But the formula in the cell is correct! =Sum(A1:A12). When I check the formatting under Format Cells I see that the Format is "Accounting" but even if I change it back to Number or Custom it doesn't make a change. I can only fix it by copying another Sum Formula and paste it using Paste Special - Value. However, this starts to annoy me now. Why is this happening or what am I am doing wrong that I get those errors in my formulas? Any ideas? Nicol...

Recommendations for Xml Editor Component that can be hosted in WinForm
Hey, I am looking for recommendations for a component that supports Xml editing that can be hosted in a .Net application. Free or Commercial. Thanks in advance! Best regards, Bill ...

Get Window from point
Hi, Is there a way to get a window from a given point ? Yoav. Hi, WindowFromPoint might be what you are looking after. Emmanuel On Jul 2, 9:22 am, "Yoavo" <y...@cimatron.co.il> wrote: > Hi, > Is there a way to get a window from a given point ? > > Yoav. "Yoavo" <yoav@cimatron.co.il> wrote in message news:OrWPimHvHHA.4736@TK2MSFTNGP05.phx.gbl... > Hi, > Is there a way to get a window from a given point ? > Try WindowFromPoint. -- Jeff Partch [VC++ MVP] http://msdn2.microsoft.com/en-us/library/ww1kxcy0(VS.80).aspx Note that th...

Get totals from other sheet
While on SHEET 2 I would like a macro that would check the last entry in any given column on sheet one.Thanks A small clarification: the last entry on any col could be a date or a number Thanks "pcor" wrote: > While on SHEET 2 I would like a macro that would check the last entry in any > given column on sheet one.Thanks ...

What happens to the original email when it gets made into a task?
When I drag an email to the task button to create a task, is the original email then moved? Or only a copy? I'm using outlook 2007, switching from Entourage on mac. thanks, sharon Drag, yes. Ctrl+ drag, no.=20 --=20 Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for=20 Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx =20 <sselden13@gmail.com> wrote in message = news:1170031513.420376.88160@j27g2000cwj.google...

After Update add something to the end of a field
using MS Access 2003 I need to have an "after update" or something similar to automatically add this text to the end of a field "@mhsfax.com". I want to be able to enter a number in the field and have @mhsfax.com automatically added to the end of the number. How do I do this? On Wed, 15 Aug 2007 14:53:41 -0700, serviceenvoy@gmail.com wrote: > using MS Access 2003 > I need to have an "after update" or something similar to automatically > add this text to the end of a field "@mhsfax.com". I want to be able > to enter a number in the field...

sharing the calendar over a network without Exchange server
I want to share the calendar over the network, but Exchange Server is not being used. The network is on a domain. Server is running Back Office 2000 and the stations are using XP Pro. Using Outlook 2002 Check this page: http://www.slipstick.com/outlook/share.htm -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! "Gary" <anonymous@discussions.microsoft.com> wrote in message news:023401c39ffc$68f02750$a501...

Report based on Record Totals
I need to create a report based on the total amount of records there are in about 8 different queries. I don't need any of the information except the total amount of records that there are. Any help would be appreciated. -Anthony Morano SELECT COUNT(*) As countInQ1, (SELECT COUNT(*) FROM q2) As countInQ2, (SELECT COUNT(*) FROM q3) As countInQ3, ... (SELECT COUNT(*) FROM q8) As countInQ8 FROM q1 where I assume the queries name are q1, q2, ... q8 If you want 8 rows, rather than one, try: SELECT COUNT(*) As myCount, 1 as queryNumber FROM q1 UNION ALL SELECT COUN...

quickest way to populate hyperlinks
Wondering the best way to set up files to quickly populate the table/form for a products table that has hyperlink fields. Some examples of the fields are prod.id(text) MSDS(hyperlink), Specsheet(hyperlink),etc. there are at least 15 hyperlink fields for each prod. Do I have to right click on each record of each field an got to Edit hyperlink to go get the file - any quicker way???? thanks, barb Dear Babs: Download the applet that I put together to demonstrate a hyperlinks ListBox at http://www.emrupdate.com/files/folders/al_borges/entry58232.aspx Cheers, Al "babs" wrot...

How to get pixel coordinates and RGB values when cursor moves over an image?
Hi, I have a simple custom control (inherits from UserControl) that displays an image (not a pictureBox). My goal is to get the pixel coordinates and the RGB values of a pixel that the mouse is hovering over and display that information in the status bar of my application. Since this is an image viewing application, the image displayed on the control is always changing, and there are two viewing modes: 1. the image streches the boundaries of the control (enables autoscroll if necessary) to fit its contents. 2. if the image size iz bigger than the clientsize of the control, the image ...

IF statement based on True/False that activates a certain list box
I've been asked to create a formula that will react to either "yes" or "no" entered into a cell which will show options in another cell based on a certain list. Example: Cells D3:D5 contain the values Monday, Tuesday, Wednesday (list named BegWeek) Cells E3:E5 contain the values Thursday, Friday, Saturday (list named EndWeek) Cell A3 accepts either "yes" or "no" entry only from a list If A3 = "Yes" then B3 will = drop down list BegWeek If A3 = "No" then B3 will = drop down list End Week I don't even know if thi...

How to do save time on data entry?
I would like to know how to design a form on date entry based on the sample given below let say Group A: Staff: Fred Produce Art/Tkt: 8574/120, 2299/140, SOFT/150 Staff: Nic Produce Art/Tkt: 5335/150, 7799/120, 8251/120 tat mean in Group A got 2 staff, each of the staff produce different type of Art/Tkt in 1 days. I would like to know how to set the form design so that I can key in Staff name once but i can key in a lot of art/tkt produce by that staff in 1 form. Hope to hear some tips bout it. Thank for your reply. Here is a sample database - that shows similar situation only using boo...

integration manager 10.0-SQL Data Source
We are trying to run an integration by using a link to the GP tables. One of our data sources is using the SQL Server as the data source. We can query the data source and return all rows in the integration. However, when we run the integration we receive the error: An error handler was not found for: Object reference not set to an instance of an object. We are on the latest service pack too. Are you using any field script or event script in IM? Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com The Dynamics GP Blogst...

How can I get a copy of every email I send?
Rachael wrote: <nothing> Eh? PLEASE write your question in the body of the post and NOT just the subject as it gets truncated like yours has Have a look here: http://dts-l.org/goodpost.htm -- Gordon Burgess-Parker Interim Systems and Management Accounting www.gbpcomputing.co.uk 18/04/2005 10:47:31 Rachael <Rachael@discussions.microsoft.com> wrote in message <B385860F-641F-4D25-9569-0DD6FCFE6169@microsoft.com> Doesn't your copy of Outlook save everything in the 'sent items' folder anyway? If not I would create a rule in Outlook (tools/organise/rule...

Is there a way I can only print the reply instead of the entire email message
I wonder if there is a way I can only print the reply to an email message, instead of printing the entire message? My choice for selection only seem to be gone with Outlook 2003 printing options. Any help is appreciated.............Peter ...

lost my calendar
Well, I'm having some serious troubles. I hope someone can offer me a way out of this mess. For reasons irrelevant to this post, I believed that my Outlook profile was corrupt. I followed the instructions at this page to the best of my ability: http://www.howto-outlook.com/faq/newprofile.htm After I was done creating the new profile, I went to Control Panel > Mail and removed the old profile. Now, however, I realize that my old Outlook calendar is gone. I thought that it had been duplicated or something in new profile, but I was clearly wrong. Is there any way to get that C...

Server Freezes
Hi All , I Have Windows 2000 Server which is a file server in our organization , The problem is that it freezes occassionally it doesnt allow me to do "ctrl alt del" to restart or shutdown the File Server .Finally i have to hard boot the server . Since this File Server is Mapped to the Client Computer as a Network drive , All the users who are connected unable to open this network drive .After rebooting the Server it runs perfectly without any problem with great speed. I am also facing the same problem with Windows 2003. Hardware side everything is fine No fan Or heat Sink Proble...

Quickest way to remove a filter?
When I'm looking at a particular list (such as notes) where I've filtered the list, I see the words "Filter Applied" in the upper right hand corner. Is there any way to quickly remove that filter without going through the Customize current view menu option? ...

How do I get macro to unmerge cells that have been previously merg
When I try to record the steps to unmerge 2 previously merged colums into 2 separate colums into a macro, when the macro is executed it tries to merge the colums instead of unmerging them? If I do the same steps without recording as a macro the unmerge works fine. Is there a trick invloved in recording a macro to do unmerging? Hmmmm not sure what's happening. Are you sure the cells you ar unmerging are merged (probably a daft question), merge/unmerge is toggle. Keyboard strokes are better than the mouse when using the record macr function, eg Ctrl+1 Alt+m Ente -- tghcog -------...

Help with simple sales data base
Hi need help with a school project for one of my off spring ;) They are writing a simple sales database and have become stuck. Any help would be appreciated. We have an Orders table, Customers table (with a link to orders) and a product table. What we are trying to do is have an orders form where you select a customer (done that), and have a subreport pick out the products you are selling - however I cant figure out how to link products to orders as i may have many lines of products on one order and wish to show totals etc? Any pointers.... On 5 mrt, 21:47, CP <C...@di...

Any way to mark junk as read automatically
I can't seem to find a way to configure message rules to mark all junk mail as already read. Is there any way to do this? Mail that goes into the junk folder is always junk so I'm sick of having to go in there, right clicking the message and clicking mark as read just to stop it showing up as a number beside the folder ie Junk (1) Thanks in advance. Pip Why bother with marking it read? Simply click the X to the right of the Junk E-mail folder which enables you to empty that whole folder with one more click. Gary VanderMolen, Microsoft MVP (Mail) ----------------...

add microsoft publisher to existing version of microsoft office
New notebook computer came with Microsoft Office Student and Teacher edition pre-installed. However, I want to add Microsoft Publisher. Is this possible and how? Buy Publisher, then install it. "SANDYB" <SANDYB@discussions.microsoft.com> wrote in message news:E1052B38-B9CF-4549-861F-A8768095D585@microsoft.com... | New notebook computer came with Microsoft Office Student and Teacher edition | pre-installed. However, I want to add Microsoft Publisher. Is this possible | and how? ...