473,395 Members | 1,530 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,395 software developers and data experts.

Working with XML files

Hi all!

I have a XML file that is read by a C# program.
The file looks like this:

<EMailList>
<email>ed*************@misys.com</email>
</EMailList>
<EMailList>
<email>ro***********@misys.com</email>
</EMailList>

But I want that this file look like this:

<EMailList>
<email>ed*************@misys.com</email>
<email>ro***********@misys.com</email>
</EMailList>

But, when I do that my program blows up.

The code to read the file is that:

public class COpicsXMLOperations
{

#region XMLConfigFile
static public DataSet dsOpicsSystemBuilder;
static public DataSet dsOpicsSBUsers;
#endregion

static public DataSet DS_OpicsSystemBuilder
{
get
{
if (dsOpicsSystemBuilder==null)
{
dsOpicsSystemBuilder = new DataSet();

// Creating EMailList table
DataTable dtEMailList = new DataTable("EMailList");
DataColumn dcEMail = new DataColumn("email");
dtEMailList.Columns.Add(dcEMail);
dsOpicsSystemBuilder.Tables.Add(dtEMailList);
}
return dsOpicsSystemBuilder;
}
}

private void FrmProcParam_Load(object sender, System.EventArgs e)
{
// Clear the list to avoid duplicates
clb_EMails.Items.Clear();
this.txt_Emails.Focus();

// Read the e-mails against the XML file
COpicsXMLOperations.DS_OpicsSystemBuilder.Tables.C lear();
COpicsXMLOperations.DS_OpicsSystemBuilder.ReadXml( "OpicsSystemBuilder.xml");
This is the line that blows up.

The error is:

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll

Additional information: Cannot remove a table that has existing relations.
Remove relations first.

The program '[2304] OpicsSystemBuilder.exe' has exited with code 0 (0x0).

Anybody can help me with this?

Thanks!

Eduardo

--
Eduardo de Morais Ferrari
Misys'' OPICS Project
Stefanini IT Solutions
White Plains, NY
Phone: (914) 821-2727
Cell: (914) 406-5027
ed*************@misys.com
Nov 22 '05 #1
2 1708
hi Eduardo,
did you try clearing the relations as the error suggested?
somewhere along the way, a relation must be created between tables in the
dataset. the first version of your xml file includes multiple tables, this
could be the reason for a relation being inferred unless you created them
yourself. you could debug before the error happens and examine the
Dataset.Relations property to see what kind of relation exists.

hope this helps
tim
--------------------------
blog: http://tim.mackey.ie
"Ferrari, Eduardo" <ed*************@misys.com> wrote in message
news:72**********************************@microsof t.com...
Hi all!

I have a XML file that is read by a C# program.
The file looks like this:

<EMailList>
<email>ed*************@misys.com</email>
</EMailList>
<EMailList>
<email>ro***********@misys.com</email>
</EMailList>

But I want that this file look like this:

<EMailList>
<email>ed*************@misys.com</email>
<email>ro***********@misys.com</email>
</EMailList>

But, when I do that my program blows up.

The code to read the file is that:

public class COpicsXMLOperations
{

#region XMLConfigFile
static public DataSet dsOpicsSystemBuilder;
static public DataSet dsOpicsSBUsers;
#endregion

static public DataSet DS_OpicsSystemBuilder
{
get
{
if (dsOpicsSystemBuilder==null)
{
dsOpicsSystemBuilder = new DataSet();

// Creating EMailList table
DataTable dtEMailList = new DataTable("EMailList");
DataColumn dcEMail = new DataColumn("email");
dtEMailList.Columns.Add(dcEMail);
dsOpicsSystemBuilder.Tables.Add(dtEMailList);
}
return dsOpicsSystemBuilder;
}
}

private void FrmProcParam_Load(object sender, System.EventArgs e)
{
// Clear the list to avoid duplicates
clb_EMails.Items.Clear();
this.txt_Emails.Focus();

// Read the e-mails against the XML file
COpicsXMLOperations.DS_OpicsSystemBuilder.Tables.C lear();
COpicsXMLOperations.DS_OpicsSystemBuilder.ReadXml( "OpicsSystemBuilder.xml");
This is the line that blows up.

The error is:

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll

Additional information: Cannot remove a table that has existing relations.
Remove relations first.

The program '[2304] OpicsSystemBuilder.exe' has exited with code 0 (0x0).

Anybody can help me with this?

Thanks!

Eduardo

--
Eduardo de Morais Ferrari
Misys'' OPICS Project
Stefanini IT Solutions
White Plains, NY
Phone: (914) 821-2727
Cell: (914) 406-5027
ed*************@misys.com

Nov 22 '05 #2
Hi Tim!

Yes, I did. And I did not set any relations on this table.

Eduardo
--
Eduardo de Morais Ferrari
Misys'''''''' OPICS Project
Stefanini IT Solutions
White Plains, NY
Phone: (914) 821-2727
Cell: (914) 406-5027
ed*************@misys.com
"Tim_Mac" wrote:
hi Eduardo,
did you try clearing the relations as the error suggested?
somewhere along the way, a relation must be created between tables in the
dataset. the first version of your xml file includes multiple tables, this
could be the reason for a relation being inferred unless you created them
yourself. you could debug before the error happens and examine the
Dataset.Relations property to see what kind of relation exists.

hope this helps
tim
--------------------------
blog: http://tim.mackey.ie
"Ferrari, Eduardo" <ed*************@misys.com> wrote in message
news:72**********************************@microsof t.com...
Hi all!

I have a XML file that is read by a C# program.
The file looks like this:

<EMailList>
<email>ed*************@misys.com</email>
</EMailList>
<EMailList>
<email>ro***********@misys.com</email>
</EMailList>

But I want that this file look like this:

<EMailList>
<email>ed*************@misys.com</email>
<email>ro***********@misys.com</email>
</EMailList>

But, when I do that my program blows up.

The code to read the file is that:

public class COpicsXMLOperations
{

#region XMLConfigFile
static public DataSet dsOpicsSystemBuilder;
static public DataSet dsOpicsSBUsers;
#endregion

static public DataSet DS_OpicsSystemBuilder
{
get
{
if (dsOpicsSystemBuilder==null)
{
dsOpicsSystemBuilder = new DataSet();

// Creating EMailList table
DataTable dtEMailList = new DataTable("EMailList");
DataColumn dcEMail = new DataColumn("email");
dtEMailList.Columns.Add(dcEMail);
dsOpicsSystemBuilder.Tables.Add(dtEMailList);
}
return dsOpicsSystemBuilder;
}
}

private void FrmProcParam_Load(object sender, System.EventArgs e)
{
// Clear the list to avoid duplicates
clb_EMails.Items.Clear();
this.txt_Emails.Focus();

// Read the e-mails against the XML file
COpicsXMLOperations.DS_OpicsSystemBuilder.Tables.C lear();
COpicsXMLOperations.DS_OpicsSystemBuilder.ReadXml( "OpicsSystemBuilder.xml");
This is the line that blows up.

The error is:

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll

Additional information: Cannot remove a table that has existing relations.
Remove relations first.

The program '[2304] OpicsSystemBuilder.exe' has exited with code 0 (0x0).

Anybody can help me with this?

Thanks!

Eduardo

--
Eduardo de Morais Ferrari
Misys'' OPICS Project
Stefanini IT Solutions
White Plains, NY
Phone: (914) 821-2727
Cell: (914) 406-5027
ed*************@misys.com


Nov 22 '05 #3

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

Similar topics

1
by: Moosebumps | last post by:
So say I am working on two separate .py files in IDLE that are part of the same program. Does anyone have problems where when you modify one file, and then run the other, the changes you made in...
4
by: Jerry | last post by:
I'm having just a bit of trouble wrapping my brain around the task of working with folders that are above the site's root folder. I let users upload photos (.jpg/.gif files) which can...
14
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
4
by: Axter | last post by:
Sorry for OT question, but does any one have a working *.bat file to get Comeau to work with VC++ 7.1, VC++ 8.0, or GNU 3.x compilers. I've tried everything I can think off, to get it to work,...
1
by: saturday | last post by:
I was having problems getting mysql to work with php on my apache server. Thankfully I got it working after reading a different thread, which had me copy over the libmysql file to the apache/bin...
0
by: George2 | last post by:
Hello everyone, From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a machine running IIS 6.0. I just replaced the web.config and several aspx pages in the application and now the style sheets are not working. the images from the themes work but not the css...
3
by: Seth Williams | last post by:
I have done some new development on older files, locally - then I copy the files, along with the .vb files for the webservices, to our DEV server. Now, mysteriously, no web services are running - I...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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.