Solved

How to get the original value in dataset.

Posted on 2003-11-07
4
2,066 Views
Last Modified: 2012-08-14
I have to get the previous value of a certain cell in a datagrid.

I used dataset.getchanges to get the rows that has changed.

On modified rows I will update the database using a stored procedure. It is impossible that I use the ds.update since the dataset table is not equal to the real database table.

What I did was, I used the sqlcommand object to call the stored proc.

My problem is, in passing parameters to an update procedure, you need to provide the primary key values of the table. But in my case, the primary column is also changeable. I need to know the original value of the row i am going to save.

Thanks in advance.
0
Comment
Question by:Pea913
4 Comments
 
LVL 5

Expert Comment

by:arvindb1
ID: 9700044
Clone the dataset after populating like this
Dim ods1 As DataSet = ods.Clone()
then use one dataset for old values and new dataset for changed values, then you can have the values.

Arvind
0
 

Author Comment

by:Pea913
ID: 9700110

I already did that.

But my problem is, the return recordset of getchanged, does not include the original row number. I still cannot refer it to the cloned dataset.

Flor
0
 
LVL 2

Expert Comment

by:sedmans
ID: 9701031
A quick and dirty solution to this problem is to have the primary key values in your dataset twice.

Once for reference (and not displayed in the datagrid) and once displayed in the datagrid so that they can be changed.
0
 
LVL 4

Accepted Solution

by:
wile_e_coyote earned 135 total points
ID: 9701445
The DataSet keeps the original and current values for each column.   There is no need to clone the dataset or return the column twice.  You can index the column by column name and "version as follows (sorry this is C# not VB)

DataSet ds = MyGridDataSet.GetChanges();
DataRow dr = ds.Tables[0].Rows[0];  

string sOld = dr ["KeyColumnName", DataRowVersion.Original].ToString();
string sCurrent = dr ["KeyColumnName", DataRowVersion.Current].ToString();
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question