newbie: DataSet update question

D

deko

I can get my DataSet to update with code in the constructor of the class
that creates the DataSet, but not using a method in that same class.

Why is this?

private DataSet projectData;

//this is the constructor of class AsaDataAccess
public AsaDataAccess()
{
projectData = new DataSet();
projectData.ReadXml(xmlFile);
DataRow dr = projectData.Tables["TableConfiguration"].NewRow();
dr["Project_ID"] = 1;
dr["ConfigurationName"] = "test";
projectData.Tables["TableConfiguration"].Rows.Add(dr);
projectData.AcceptChanges();
}

If I put this same code in a method, it will not update the Dataset, and no
error is raised

public void MyMethod()
{
DataRow dr = projectData.Tables["TableConfiguration"].NewRow();
dr["Project_ID"] = 1;
dr["ConfigurationName"] = "test";
projectData.Tables["TableConfiguration"].Rows.Add(dr);
projectData.AcceptChanges();
}

???

How can I update my DataSet using a method?
 
A

Aboulfazl Hadi

Hi deko
I don't think so.For updating dataset is not neccessary to put your
code in the constructor.Call MyMethod again, if it is working in
constructor, then it must work in the method.

Best Regards,
A.Hadi
 
D

deko

I don't think so.For updating dataset is not neccessary to put your
code in the constructor.Call MyMethod again, if it is working in
constructor, then it must work in the method.

Thanks for the reply. It's strange behavior and I don't understand it. I
was researching constraints, but that does not appear to be it. The only
other thing I can think of is that the modal form that calls the method is
hitting some kind of lock.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top