473,396 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Jul 26 '06 #1
3 1174
"MurdockSE" <mu*****@nc.rr.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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
Jul 26 '06 #2
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

Jul 26 '06 #3
I got the answer/s I was looking for here:

http://groups.google.com/group/micro...9226fef?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

Jul 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
4
by: pantichd | last post by:
<I also posted this on microsoft.public.vsnet.debugging 'cuz I didn't know which was more appropriate or would get quickest response> Hello, Can someone tell me how I can view the contents...
12
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
7
by: Ryan | last post by:
OK, here's my setup. I have a treeview control that is populated with records from a Product table, and it allows "checking". This is used for my automatic notification system. Say a particular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.