473,388 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Posted in VB without a response, trying here.

I have a class that I populate properties from a table in my database. I
create the properties in my class one for one with the columns in the tables
that I use to fill the class. Some properties are not loaded until a
function is called to load the properties when needed. In this class I have
about 50 properties that I expose to the client. The client, in turn, can
update most of the properties with new data, then call the update function.
So far so good.

However, I need to only update the properties that have changed. So I have
a Private Sub that records the table name, column name, old value, and new
value when a property is set and the values are different. This sub creates
a collection of property changes and then on the update I want to just send
the updates to the database.

Is there a better way to keep track of the properties that have changed for
the update function? I need to keep the old property value and the new
property value for auditing purposes. I was thinking of calling the
function on the property set function.

John
Sep 17 '07 #1
1 1070
John,

You can use a DataRow/DataTable/DataSet. When you load the data into a
row, the RowState is equal to DataRowState.Unchanged. When you change any
of the values in the row, the state is changed to DataRowState.Modified.

When you normally deal with a DataRow, you are using the current values.
When you get a value using the indexer (the Item property), it is the same
as calling it with the string/integer/DataColumn instance, and passing a
value of DataRowVersion.Current.

If you want to get the original values, you can pass the
string/integer/DataColumn instance to the indexer, along with the
DataRowVersion.Original value to get the original values.

Or, if you want to work with two separate DataRow instances, you can
create a DataView on the DataTable, passing in the value of
DataViewRowState.OriginalRows to get the original values.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wright" <ri***********@hotmail.comwrote in message
news:ud****************@TK2MSFTNGP05.phx.gbl...
>I have a class that I populate properties from a table in my database. I
create the properties in my class one for one with the columns in the
tables
that I use to fill the class. Some properties are not loaded until a
function is called to load the properties when needed. In this class I
have
about 50 properties that I expose to the client. The client, in turn, can
update most of the properties with new data, then call the update
function.
So far so good.

However, I need to only update the properties that have changed. So I
have
a Private Sub that records the table name, column name, old value, and new
value when a property is set and the values are different. This sub
creates
a collection of property changes and then on the update I want to just
send
the updates to the database.

Is there a better way to keep track of the properties that have changed
for
the update function? I need to keep the old property value and the new
property value for auditing purposes. I was thinking of calling the
function on the property set function.

John


Sep 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ghazan Haider | last post by:
I am posting this for the lack of a better newsgroup, and for the knowledge of people here, and because its only partially OT. We have a bunch of users with their computers at work. There are...
4
by: Richard Hollenbeck | last post by:
The following query takes about one second to execute with less than 1,000 records, but the report that's based on it takes from 15-30 seconds to format and display. That's frustrating for both me...
1
by: Mad Scientist Jr | last post by:
How do you get a ASP.NET page to return nothing, so the page posting form data to it doesn't reload? I have tried all combinations of the following: Response.SuppressContent = True...
13
by: Tim | last post by:
Hello, Is there a way to "cancel" a response.Redirect? For example, in the code below, could I insert anything in the Catch statement that would cancel the redirect and resume flow after the...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
7
by: mattmerc | last post by:
Hi all, We have all seen lot of method for exporting datagrids to Excel. I have a slightly different need. I think it should be easy to accomplish but I am not sure how. I would like when a user...
14
by: rolfejr | last post by:
I am trying to display a PDF in the users browser that is pulled from a binary field in our database, and keep that PDF from caching on the client computer. I can successfully pull the PDF and...
2
by: Keith Harris | last post by:
Hi, I would like to display a preview of a posted file. To accomplish, this I am using storing the image bytes into cache and setting the ImageUrl property of an image control to an aspx page...
18
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
5
by: Jonathan Kay | last post by:
Hi, I'd like to my WCF webservice to work both on SSL and without. Unfortunately searching has led to dead ends, references to changes that only work on the old previous beta versions and I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.