find out if a field has changed in a datatable

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.

LVL 4
brokeMyLegBikingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jojo1771Commented:
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
MsFoxCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brokeMyLegBikingAuthor Commented:
MsFox, that sounds right, let me try that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.