Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changes To DataSet Not Being Saved
Message
From
01/10/2008 18:58:56
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01352069
Message ID:
01352155
Views:
22
Kevin,

Certain circumstances leaves a DataRow in a "Proposed" state ... which simply means that the data has not been "moved" into the "Current" state. You can see this if you check oRow.HasVersion(DataRowState.Proposed) ... it will be true. (I think that's the right syntax, this is off the top of my head).

Anyway, in order to get it from the Proposed state, you need to Commit the Proposed changes. There are several ways to do this, but why don't you start out with this concept and see if it solves the problem, this seems to be the most foolproof methodology:
		DataRow oRow = oDataSet.Tables[0].Rows[0].EndEdit();

		oAdapter.Update(oDataSet, sTableName);
~~Bonnie




>I have the dataset bound to textboxes on the form:
>
>
>txtTitle.DataBindings.Add("Text", oDataSet, "ItemRow.Title");
>txtCategory.DataBindings.Add("Text", oDataSet, "ItemRow.Category");
>txtAuthor.DataBindings.Add("Text", oDataSet, "ItemRow.Author");
>txtCatNo.DataBindings.Add("Text", oDataSet, "ItemRow.Catalogue_No");
>txtIsbn.DataBindings.Add("Text", oDataSet, "ItemRow.Isbn");
>txtPublisher.DataBindings.Add("Text", oDataSet, "ItemRow.Publisher");
>
>
>In SaveChanges I then pass the oDataSet variable to this code in my Data Access class:
>
>
>public bool UpdateDataSet(DataSet oDataSet, string sTableName)
>{
>	bool bRetVal = true;
>
>	try
>	{
>		DataRow oRow = oDataSet.Tables[0].Rows[0];
>		DataRowState state = oRow.RowState;                \\state = Unchanged
>
>		oAdapter.Update(oDataSet, sTableName);
>	}
>	catch(SqlException e)
>	{
>		oException = e;
>		bRetVal = false;
>	}
>	return bRetVal;
>}
>
>
>
>The DataAdapater is stored as oAdapter on the data access class. When I run this, it doesn't error, but it also doesn't save.
>
>Anyone wanna set a newbie straight?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform