I have tried every combination I can think of, but I cannot get this to
work. Has anyone got any suggestions?
When I run this code I get the three <add> statements under the
<configuration> element and not under the <appSettings> element.
Richard
www.grimes.demon.co.uk
#using <mscorlib.dll>
#using <system.data.dll>
#using <system.dll>
#using <system.xml.dll>
using namespace System;
using namespace System::Data;
void ChangeValue(DataSet* data, String* name, String* value)
{
DataTable* dt = data->Tables->Item[S"appSettings"];
if (dt != 0)
{
DataRelation* add = dt->ChildRelations->Item[S"appSettings_add"];
if (add != 0)
{
DataTable* addTable = add->ChildTable;
DataRow* dr = addTable->NewRow();
dr->Item[S"key"] = name;
dr->Item[S"value"] = value;
addTable->Rows->Add(dr);
}
}
}
void main()
{
DataSet* data = new DataSet;
data->ReadXml(
AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
ChangeValue(data, S"One", S"1");
ChangeValue(data, S"Two", S"2");
ChangeValue(data, S"Three", S"3");
data->AcceptChanges();
data->WriteXml(
AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
}
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.