DataRow not updating...

  • Thread starter Thread starter jack
  • Start date Start date
J

jack

using the following code, I've been unable to write an updated xml document.I can see the xml
file get refreshed but even at that, it writes in the original contents. these procs come from a
databaseengine class i created, theDataStore is a dataset that gets loaded from a xml data file
when the constructor runs.

the database engine sits in a application variable within a IIS application and only one copy ever
exist in memory. updateUser is called via delegate.

all this, and writexml() technically DOES write xml, it just has a thing for defaults.

public void updateUser (zDatabaseObject theObject)
{
zUser theUser = (zUser) theObject;

DataRow theRow;
theRow = theDataStore.Tables["tblUsers"].Rows.Find(theUser.UserID);

theRow["FullName"] = theUser.FullName;
theRow["UserName"] = theUser.UserName;
theRow["Password"] = theUser.Password;
theRow["Email"] = theUser.Email;
theRow.AcceptChanges();

saveDataStore();
}

private void saveDataStore()
{
theDataStore.AcceptChanges();
theDataStore.WriteXml(theRootDirectory + "zDatabase.xml");
}
 
Hi Jack,

Try calling theRow.EndEdit().

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

using the following code, I've been unable to write an updated xml document.I can see the xml
file get refreshed but even at that, it writes in the original contents. these procs come from a
databaseengine class i created, theDataStore is a dataset that gets loaded from a xml data file
when the constructor runs.

the database engine sits in a application variable within a IIS application and only one copy ever
exist in memory. updateUser is called via delegate.

all this, and writexml() technically DOES write xml, it just has a thing for defaults.

public void updateUser (zDatabaseObject theObject)
{
zUser theUser = (zUser) theObject;

DataRow theRow;
theRow = theDataStore.Tables["tblUsers"].Rows.Find(theUser.UserID);

theRow["FullName"] = theUser.FullName;
theRow["UserName"] = theUser.UserName;
theRow["Password"] = theUser.Password;
theRow["Email"] = theUser.Email;
theRow.AcceptChanges();

saveDataStore();
}

private void saveDataStore()
{
theDataStore.AcceptChanges();
theDataStore.WriteXml(theRootDirectory + "zDatabase.xml");
}
 
thx for the reply, but....

Have tried that, along with begin edits at the beginning of the
update. still no luck. In the meantime i've writtin a little gui app
to test this and it seems to work using the same calls i am using
here.

according to some other messages, others claim it's due to the dataset
being a different instance. though if that is the case the way i have
my code then it would be writing a empty xml file as opposed to the
one it originally loaded.

this problem is starting to exhaust me, many people with the problem
but once they fix it they just say "i found the problem" hehe... so if
i find the error i will post it.
 
Hi Steve,

Can you create a little sample?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Steve Haun said:
thx for the reply, but....

Have tried that, along with begin edits at the beginning of the
update. still no luck. In the meantime i've writtin a little gui app
to test this and it seems to work using the same calls i am using
here.

according to some other messages, others claim it's due to the dataset
being a different instance. though if that is the case the way i have
my code then it would be writing a empty xml file as opposed to the
one it originally loaded.

this problem is starting to exhaust me, many people with the problem
but once they fix it they just say "i found the problem" hehe... so if
i find the error i will post it.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Jack,

Try calling theRow.EndEdit().

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

using the following code, I've been unable to write an updated xml
document.I can see the xml
file get refreshed but even at that, it writes in the original
contents. these procs come from a
databaseengine class i created, theDataStore is a dataset that gets
loaded from a xml data file
when the constructor runs.

the database engine sits in a application variable within a IIS
application and only one copy ever
exist in memory. updateUser is called via delegate.

all this, and writexml() technically DOES write xml, it just has a
thing for defaults.

public void updateUser (zDatabaseObject theObject)
{
zUser theUser = (zUser) theObject;

DataRow theRow;
theRow =
theDataStore.Tables["tblUsers"].Rows.Find(theUser.UserID);

theRow["FullName"] = theUser.FullName;
theRow["UserName"] = theUser.UserName;
theRow["Password"] = theUser.Password;
theRow["Email"] = theUser.Email;
theRow.AcceptChanges();

saveDataStore();
}

private void saveDataStore()
{
theDataStore.AcceptChanges();
theDataStore.WriteXml(theRootDirectory + "zDatabase.xml");
}
--
 
will do...

Miha Markic said:
Hi Steve,

Can you create a little sample?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Steve Haun said:
thx for the reply, but....

Have tried that, along with begin edits at the beginning of the
update. still no luck. In the meantime i've writtin a little gui app
to test this and it seems to work using the same calls i am using
here.

according to some other messages, others claim it's due to the dataset
being a different instance. though if that is the case the way i have
my code then it would be writing a empty xml file as opposed to the
one it originally loaded.

this problem is starting to exhaust me, many people with the problem
but once they fix it they just say "i found the problem" hehe... so if
i find the error i will post it.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Jack,

Try calling theRow.EndEdit().

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

using the following code, I've been unable to write an updated xml
document.I can see the xml
file get refreshed but even at that, it writes in the original
contents. these procs come from a
databaseengine class i created, theDataStore is a dataset that gets
loaded from a xml data file
when the constructor runs.

the database engine sits in a application variable within a IIS
application and only one copy ever
exist in memory. updateUser is called via delegate.

all this, and writexml() technically DOES write xml, it just has a
thing for defaults.

public void updateUser (zDatabaseObject theObject)
{
zUser theUser = (zUser) theObject;

DataRow theRow;
theRow =
theDataStore.Tables["tblUsers"].Rows.Find(theUser.UserID);

theRow["FullName"] = theUser.FullName;
theRow["UserName"] = theUser.UserName;
theRow["Password"] = theUser.Password;
theRow["Email"] = theUser.Email;
theRow.AcceptChanges();

saveDataStore();
}

private void saveDataStore()
{
theDataStore.AcceptChanges();
theDataStore.WriteXml(theRootDirectory + "zDatabase.xml");
}
--
 
Now aint that a **** hehe...

wrote a little test app which has the exact same structure as the bigger
one, however the test works and the main does not... all i did was delete
out extra fields and several overloaded methods i had to match.

http://zhaun.net/zTestApp.zip

not the best method of data access for updates, was planning on improving it
with postponed writes. till i actually get it to write there is no sence in
doing so.



Miha Markic said:
Hi Steve,

Can you create a little sample?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Steve Haun said:
thx for the reply, but....

Have tried that, along with begin edits at the beginning of the
update. still no luck. In the meantime i've writtin a little gui app
to test this and it seems to work using the same calls i am using
here.

according to some other messages, others claim it's due to the dataset
being a different instance. though if that is the case the way i have
my code then it would be writing a empty xml file as opposed to the
one it originally loaded.

this problem is starting to exhaust me, many people with the problem
but once they fix it they just say "i found the problem" hehe... so if
i find the error i will post it.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Jack,

Try calling theRow.EndEdit().

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

using the following code, I've been unable to write an updated xml
document.I can see the xml
file get refreshed but even at that, it writes in the original
contents. these procs come from a
databaseengine class i created, theDataStore is a dataset that gets
loaded from a xml data file
when the constructor runs.

the database engine sits in a application variable within a IIS
application and only one copy ever
exist in memory. updateUser is called via delegate.

all this, and writexml() technically DOES write xml, it just has a
thing for defaults.

public void updateUser (zDatabaseObject theObject)
{
zUser theUser = (zUser) theObject;

DataRow theRow;
theRow =
theDataStore.Tables["tblUsers"].Rows.Find(theUser.UserID);

theRow["FullName"] = theUser.FullName;
theRow["UserName"] = theUser.UserName;
theRow["Password"] = theUser.Password;
theRow["Email"] = theUser.Email;
theRow.AcceptChanges();

saveDataStore();
}

private void saveDataStore()
{
theDataStore.AcceptChanges();
theDataStore.WriteXml(theRootDirectory + "zDatabase.xml");
}
--
 
Just so this is officially resolved... i found my error...

I was populating the fields on the form without checking ispostback... aka
before the fields were used to capture the update they were replaces with
the original values.

very stupid error, sorry to waste anyone's time.

shalafi said:
Now aint that a **** hehe...

wrote a little test app which has the exact same structure as the bigger
one, however the test works and the main does not... all i did was delete
out extra fields and several overloaded methods i had to match.

http://zhaun.net/zTestApp.zip

not the best method of data access for updates, was planning on improving it
with postponed writes. till i actually get it to write there is no sence in
doing so.



Miha Markic said:
Hi Steve,

Can you create a little sample?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Steve Haun said:
thx for the reply, but....

Have tried that, along with begin edits at the beginning of the
update. still no luck. In the meantime i've writtin a little gui app
to test this and it seems to work using the same calls i am using
here.

according to some other messages, others claim it's due to the dataset
being a different instance. though if that is the case the way i have
my code then it would be writing a empty xml file as opposed to the
one it originally loaded.

this problem is starting to exhaust me, many people with the problem
but once they fix it they just say "i found the problem" hehe... so if
i find the error i will post it.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Jack,

Try calling theRow.EndEdit().

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

using the following code, I've been unable to write an updated xml
document.I can see the xml
file get refreshed but even at that, it writes in the original
contents. these procs come from a
databaseengine class i created, theDataStore is a dataset that gets
loaded from a xml data file
when the constructor runs.

the database engine sits in a application variable within a IIS
application and only one copy ever
exist in memory. updateUser is called via delegate.

all this, and writexml() technically DOES write xml, it just has a
thing for defaults.

public void updateUser (zDatabaseObject theObject)
{
zUser theUser = (zUser) theObject;

DataRow theRow;
theRow =
theDataStore.Tables["tblUsers"].Rows.Find(theUser.UserID);

theRow["FullName"] = theUser.FullName;
theRow["UserName"] = theUser.UserName;
theRow["Password"] = theUser.Password;
theRow["Email"] = theUser.Email;
theRow.AcceptChanges();

saveDataStore();
}

private void saveDataStore()
{
theDataStore.AcceptChanges();
theDataStore.WriteXml(theRootDirectory + "zDatabase.xml");
}
--
 
Back
Top