emferrari Posted September 16, 2005 Posted September 16, 2005 Hi all! I have a XML file that is read by a C# program. The file looks like this: <EMailList> <email>eduardo.ferrari@misys.com</email> </EMailList> <EMailList> <email>robert.sirard@misys.com</email> </EMailList> But I want that this file look like this: <EMailList> <email>eduardo.ferrari@misys.com</email> <email>robert.sirard@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.Clear(); 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 Quote
Machaira Posted September 16, 2005 Posted September 16, 2005 Sounds like you need to stick: COpicsXMLOperations.DS_OpicsSystemBuilder.Relations.Clear(); in there before reading the file Quote Here's what I'm up to.
emferrari Posted September 16, 2005 Author Posted September 16, 2005 I've tryied to... But still doesn't work! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.