Click here to Skip to main content
15,903,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: Experimenting with Multithreading Pin
CrimeanTurtle200817-Dec-08 15:10
CrimeanTurtle200817-Dec-08 15:10 
GeneralRe: Experimenting with Multithreading Pin
Luc Pattyn17-Dec-08 16:28
sitebuilderLuc Pattyn17-Dec-08 16:28 
AnswerRe: Experimenting with Multithreading Pin
N a v a n e e t h17-Dec-08 16:29
N a v a n e e t h17-Dec-08 16:29 
QuestionCannot use AddNew method for CurrencyManager with databound checkbox Pin
Vloops17-Dec-08 11:50
Vloops17-Dec-08 11:50 
QuestionHow to change MenuStrip default icon when child is maximized Pin
bcryner17-Dec-08 11:03
bcryner17-Dec-08 11:03 
AnswerRe: How to change MenuStrip default icon when child is maximized Pin
Eddy Vluggen18-Dec-08 4:47
professionalEddy Vluggen18-Dec-08 4:47 
GeneralRe: How to change MenuStrip default icon when child is maximized Pin
bcryner18-Dec-08 5:06
bcryner18-Dec-08 5:06 
QuestionAdd Table to XML file using Dataset... Pin
Greg Cetti17-Dec-08 10:11
Greg Cetti17-Dec-08 10:11 
Hello,

I am try to edit an xml file via DataSet in my C# app, by adding a new table to the structure with multiple nodes to the structure - but the table should be a child table of one of the existing Tables in the structure I have read in.

In other words:
<parenttable>
<data1>FOO


Should end up like this:
<parenttable>
<data1>FOO
<mychildtable>
<test>BAR



I'm having problems getting the table in the correct place when I write the XML after I change it. I am adding the table/fields/records, and setting up the relations, but for some reason when I process the xml the new table I have added just appends to the end of the xml file and doesnt appear in the branch where it should.

Here is the code snippet of what I'm doing:
XmlTextReader xmlreader1 = new XmlTextReader("Test.xml");

DataSet ds = new DataSet();
ds.ReadXml(xmlreader1);

DataTable newTable = new DataTable();
newTable.TableName = "MyChildTable";
newTable.Columns.Add( "NewField" );
newTable.Columns.Add( "ParentTable_ID",System.Type.GetType("System.Int32") );
ds.Tables.Add( newTable );

ds.Tables["MyChildTable"].ParentRelations.Add( "MyChildTable", ds.Tables["ParentTable"].Columns["ParentTable_ID"], ds.Tables["MyChildTable"].Columns["ParentTable_ID"], true);

DataRow newRow;
newRow = ds.Tables["MyChildTable"].NewRow();
newRow["Test"] = "Value";
newRow["ParentTable_ID"] = "1";
ds.Tables["MyChildTable"].Rows.Add(newRow);

ds.AcceptChanges();

StreamWriter myStreamWriter = new StreamWriter("Out.xml" );
ds.WriteXml(myStreamWriter);
myStreamWriter.Close();


Can anyone see what I am doing incorrectly or have any suggestions?

Thanks,
Greg
greg@ram-software.com
Questioninsert space with pattern matching. Pin
Member 232448317-Dec-08 10:02
Member 232448317-Dec-08 10:02 
AnswerRe: insert space with pattern matching. Pin
User 665817-Dec-08 10:19
User 665817-Dec-08 10:19 
GeneralRe: insert space with pattern matching. Pin
Member 232448317-Dec-08 10:36
Member 232448317-Dec-08 10:36 
QuestionWinForms - Grid View bind to xml file Pin
duk3nukem17-Dec-08 9:55
duk3nukem17-Dec-08 9:55 
AnswerRe: WinForms - Grid View bind to xml file Pin
bcryner17-Dec-08 11:12
bcryner17-Dec-08 11:12 
GeneralRe: WinForms - Grid View bind to xml file [modified] Pin
duk3nukem18-Dec-08 5:17
duk3nukem18-Dec-08 5:17 
AnswerRe: WinForms - Grid View bind to xml file Pin
AnthoJoh18-Dec-08 4:48
AnthoJoh18-Dec-08 4:48 
GeneralRe: WinForms - Grid View bind to xml file [modified] Pin
duk3nukem18-Dec-08 5:24
duk3nukem18-Dec-08 5:24 
QuestionC# and .ZIP files Pin
amityo17-Dec-08 9:01
amityo17-Dec-08 9:01 
AnswerRe: C# and .ZIP files Pin
Christian Graus17-Dec-08 9:14
protectorChristian Graus17-Dec-08 9:14 
GeneralRe: C# and .ZIP files Pin
led mike17-Dec-08 9:22
led mike17-Dec-08 9:22 
AnswerRe: C# and .ZIP files Pin
Lev Danielyan18-Dec-08 0:38
Lev Danielyan18-Dec-08 0:38 
Questionhow to put the annotation to the place where mouse click for chart control Pin
Seraph_summer17-Dec-08 8:35
Seraph_summer17-Dec-08 8:35 
QuestionVisual Studio Team System Novice - How to start Pin
Nadia Monalisa17-Dec-08 8:34
Nadia Monalisa17-Dec-08 8:34 
AnswerRe: Visual Studio Team System Novice - How to start Pin
Christian Graus17-Dec-08 9:03
protectorChristian Graus17-Dec-08 9:03 
GeneralRe: Visual Studio Team System Novice - How to start Pin
Nadia Monalisa17-Dec-08 9:18
Nadia Monalisa17-Dec-08 9:18 
GeneralRe: Visual Studio Team System Novice - How to start Pin
Christian Graus17-Dec-08 9:52
protectorChristian Graus17-Dec-08 9:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.