?
Solved

find out if a field has changed in a datatable

Posted on 2004-11-15
3
Medium Priority
?
296 Views
Last Modified: 2010-04-24
How can I find out if a field has changed in a data table?

I am trying to create an audit record of any changes that are made to the data in a table which is bound to textbox controls on a form. Before I insert a new audit record, I need to figure out which values are different from the underlying data.

0
Comment
Question by:brokeMyLegBiking
3 Comments
 
LVL 5

Expert Comment

by:Jojo1771
ID: 12590464
Well, I would define 2 data sets. Load the two at the begining of the audit, then at the time to prefomr  the audit, I would take the dataset that was tied to your datagrd or what ever. And I would comapre them line by line like this.

dim i, j as integer
i=0
while i < then dataset1.tables(0).rows.count 'no compiler in front of me  so count may not be  exactly where i typed it
j=0
While j < dataset1.tables(0).colums.count ' no compiler so you may have to explorer to find this count
if dataset1.tables(0).rows(i).item(j) = dataset2.tables(0).rows(i).items(j) then
'no diffrences so do notin
else
'diffrence here so do audit
j=j+1
end while
i=i+1
end while

0
 
LVL 1

Accepted Solution

by:
MsFox earned 1800 total points
ID: 12590561
create a view of the table

Dim dv As New DataView(Me.OfficeInfoDS.dtOfficeAddress)

               
dv.RowStateFilter = DataViewRowState.ModifiedCurrent
For Each dvItem As DataRowView In dv
if textbox1.text <> dvItem.Item("Contacts_ID"))
  ' data has changed

end if

next
0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 12592719
MsFox, that sounds right, let me try that.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

840 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