G
Guest
Hi everyone,
I know the solution to my problem is probably very simple but I just can't
seem to figure out how to do it. My problem is, I have an XML file as a
datastore, I read it into a dataset for data manipulation and update the
dataset with some edited data from the screen. However, I can't seem to make
the changes "stick" in the dataset.
Following is my code snippet:
DataSet dsCOTs = new DataSet();
dsCOTs.ReadXml(Server.MapPath("../COTS.xml"));
dsCOTs.Tables[0].PrimaryKey = new System.Data.DataColumn[]
{dsCOTs.Tables[0].Columns["cotid"]};
DataRow drCOT = dsCOTs.Tables[0].Rows.Find(this.txtCOTID.Text);
if (drCOT != null)
{
drCOT.BeginEdit();
drCOT["claimed"] = "Y";
drCOT.EndEdit();
}
dsCOTs.AcceptChanges();
System.Data.SqlClient.SqlDataAdapter da = new
System.Data.SqlClient.SqlDataAdapter();
da.Update(dsCOTs, "cot");
and the COTs.xml looks like:
<COTS>
<cot>
<id>1234</id>
<name>abcd</name>
<claimed>N</claimed>
</cot>
<cot>
<id>5678</id>
<name>efgh</name>
<claimed>N</claimed>
</cot>
</COTS>
Can someone show me how to update the "claimed" field to "Y" please. Any
suggestion is greatly appreciated, as always.
Calvin
I know the solution to my problem is probably very simple but I just can't
seem to figure out how to do it. My problem is, I have an XML file as a
datastore, I read it into a dataset for data manipulation and update the
dataset with some edited data from the screen. However, I can't seem to make
the changes "stick" in the dataset.
Following is my code snippet:
DataSet dsCOTs = new DataSet();
dsCOTs.ReadXml(Server.MapPath("../COTS.xml"));
dsCOTs.Tables[0].PrimaryKey = new System.Data.DataColumn[]
{dsCOTs.Tables[0].Columns["cotid"]};
DataRow drCOT = dsCOTs.Tables[0].Rows.Find(this.txtCOTID.Text);
if (drCOT != null)
{
drCOT.BeginEdit();
drCOT["claimed"] = "Y";
drCOT.EndEdit();
}
dsCOTs.AcceptChanges();
System.Data.SqlClient.SqlDataAdapter da = new
System.Data.SqlClient.SqlDataAdapter();
da.Update(dsCOTs, "cot");
and the COTs.xml looks like:
<COTS>
<cot>
<id>1234</id>
<name>abcd</name>
<claimed>N</claimed>
</cot>
<cot>
<id>5678</id>
<name>efgh</name>
<claimed>N</claimed>
</cot>
</COTS>
Can someone show me how to update the "claimed" field to "Y" please. Any
suggestion is greatly appreciated, as always.
Calvin