[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get the original value in dataset.

Posted on 2003-11-07
4
Medium Priority
?
2,262 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 540 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline
Suggested Courses

872 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