?
Solved

How to get the original value in dataset.

Posted on 2003-11-07
4
Medium Priority
?
2,160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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)…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

743 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