473,789 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting a new row into a dataset table

If I have this as my XML file

<?xml version="1.0" standalone="yes " ?>
- <opml>
- <body>
- <outline text="RssImport er OPML">
<outline title="CNN" htmlUrl=""
xmlUrl="http://rss.cnn.com/rss/cnn_topstories. rss" />
</outline>
</body>
</opml>

And I use this code to add a new row

System.Data.Dat aSet myds = new System.Data.Dat aSet();
myds.ReadXml(@" C:\Program Files\RSSImport er\Data\feeds.x ml");
System.Data.Dat aRow dr;
dr = myds.Tables[2].NewRow();
dr[0] = "test";
myds.Tables[2].Rows.Add(dr);
myds.AcceptChan ges();
myds.WriteXml(@ "C:\Program Files\RSSImport er\Data\feeds2. xml");

I end up with:

<?xml version="1.0" standalone="yes "?>
<opml>
<body>
<outline text="RssImport er OPML">
<outline title="CNN" htmlUrl=""
xmlUrl="http://rss.cnn.com/rss/cnn_topstories. rss" />
</outline>
</body>
<outline title="test" />
</opml>

But the new row with the title "test" should go right after the CNN entry
like this:

<?xml version="1.0" standalone="yes "?>
<opml>
<body>
<outline text="RssImport er OPML">
<outline title="CNN" htmlUrl=""
xmlUrl="http://rss.cnn.com/rss/cnn_topstories. rss" />
<outline title="test" />
</outline>
</body>
</opml>
Any idea on what I could be doing wrong?

Thanks
May 8 '06 #1
1 1779
Hello Cooper,

Because this is behavior of DataTable. What are you going to do is to apply
your own XML structure to the DataTable XML format.
It's not good idea, because DataTable Xml structure don't guarantee required
behavior in your case and could be changed any time.

What do you really need is use XSLT to transform your data from the dataTable
XML to your OMPL format (btw using DataTable is not necessary, u even could
use DataReader but more work required for transformation)

C> If I have this as my XML file
C>
C> <?xml version="1.0" standalone="yes " ?>
C> - <opml>
C> - <body>
C> - <outline text="RssImport er OPML">
C> <outline title="CNN" htmlUrl=""
C> xmlUrl="http://rss.cnn.com/rss/cnn_topstories. rss" />
C> </outline>
C> </body>
C> </opml>
C> And I use this code to add a new row
C>
C> System.Data.Dat aSet myds = new System.Data.Dat aSet();
C> myds.ReadXml(@" C:\Program Files\RSSImport er\Data\feeds.x ml");
C> System.Data.Dat aRow dr;
C> dr = myds.Tables[2].NewRow();
C> dr[0] = "test";
C> myds.Tables[2].Rows.Add(dr);
C> myds.AcceptChan ges();
C> myds.WriteXml(@ "C:\Program Files\RSSImport er\Data\feeds2. xml");
C> I end up with:
C>
C> <?xml version="1.0" standalone="yes "?>
C> <opml>
C> <body>
C> <outline text="RssImport er OPML">
C> <outline title="CNN" htmlUrl=""
C> xmlUrl="http://rss.cnn.com/rss/cnn_topstories. rss" />
C> </outline>
C> </body>
C> <outline title="test" />
C> </opml>
C> But the new row with the title "test" should go right after the CNN
C> entry like this:
C>
C> <?xml version="1.0" standalone="yes "?>
C> <opml>
C> <body>
C> <outline text="RssImport er OPML">
C> <outline title="CNN" htmlUrl=""
C> xmlUrl="http://rss.cnn.com/rss/cnn_topstories. rss" />
C> <outline title="test" />
C> </outline>
C> </body>
C> </opml>
C> Any idea on what I could be doing wrong?
C>
C> Thanks
C>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
May 8 '06 #2

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

Similar topics

0
2037
by: sql_Michael_dotnet | last post by:
Can anyone help me figure out how to insert data into SQL Server when a table to hold the data does not yet exist. I am able to insert data into a existing table in the following fashion. But what if the table does not exist? Appreciate any help I can get. Private Sub InsertData() Dim objSQLConn As New SqlConnection("SERVER=.;UID=sa;PWD=;DATABASE=MyTest;") Dim objAdapter As SqlDataAdapter
4
22421
by: Deepankar | last post by:
Hi, I was trying to change an example for SQL Server to work with Access db to insert image data. I have everything working except getting the OleDbParameter type for the image column. The table in access is : img ( id number , name Text, img number
0
1436
by: a | last post by:
I've read and split a delimited text file into a dataset. It looks fine in a datagrid (5 columns and 5,000 rows), but I've been trying, without success, to then insert the resulting dataset called "result" into a single sql table that has an auto-increment and PK column called ID, as well as the 5 columns from the dataset. Any suggestions on a way to perform the insert of the "result" dataset into the sql table?
2
4026
by: a | last post by:
NEW Post Here's my best guess at how to insert this dataset.... the code runs, but no new records are added to the sql table. I've read and split a delimited text file into a dataset. It looks fine in a datagrid (5 columns and 5,000 rows), but I've been trying, without success, to then insert the resulting dataset called "result" into a single sql table that has an auto-increment and PK column called ID,
2
4586
by: sweetness | last post by:
I'm new to this and desperately need help, I'm trying to insert into an sql db and i have no idea what to do and why. i created an sqladapter, and an sqlconnection by dragging and dropping. this is a piece of my code: Try Me.SqlInsertCommand1.CommandText = "INSERT INTO StudentInfo(STUDENTID, SURNAME, FIRST_NAMES, PASSWORD, GENDER, RESIDENCE) VALUES(' " & sNumber.Text & " ' ,' " &
7
3470
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is null going back into the stored procedure. I'm stumped and would greatly appreciate any suggestions.
0
1178
by: hzgt9b | last post by:
Using VS2003, VB.NET, Here's some pseudo code that I'm trying to get to work... if <a specific record existsthen do nothing else <insert the specific record> Endif I've got the code written, but Its not working for me...
3
17544
by: joel | last post by:
Hi guys, Im new to vb.net and i have this problem how do i insert another row into my datatable... (i guess it's like creating a for loop or something i really have no idea)... in this code i can only insert a single row. help pls...
0
2232
by: toyin | last post by:
hello, pls help look through this code its not inserting the record in dataset into the another database. i want to insert the row in the dataset into another table in another database. pls help. it urgent i submit this application. when it runs it gives: this OdbcTransaction has completed,it no longer usable. thx toyin here is the code Sub ProcessAllSynchOperations() Dim sSourceURL, sWebSiteIP As String Dim...
10
14213
by: Newbie | last post by:
howdy... i am trying to execute a statement where i insert a record with datetime values into a sql database. Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "update tbl_event set last_run = '" & nowTime & "', event_action =1, event_time = '" & nextPollTime & "' where event_id = " & IntEventID
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.