Solved

How to get the original value in dataset.

Posted on 2003-11-07
4
2,034 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
Comment Utility
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
Comment Utility

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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now