Click here to Skip to main content
15,923,051 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I've been asked to add auditing to a screen.

We have an application in vb that displays a grid. The first column is a link button. When a LB is clicked, a details area is displayed with all the fields neatly organized.

In the rowcommand event for the grid I can capture the row selected and save it in a session so I can have the "before" data.

After the user makes changes, I figure I need to save the field data and call a method to do the comparing using the saved session data as the "before" and the displayed (changed) data as the "after".

I was briefly instructed to use a collection and a For Each Next routine to do it.

The problem is I'm somewhat new to all this and don't know how to put it all together.

What I have tried:

I've researched online and soon discovered this to be a daunting task that others have encountered but what they were doing was more complicated than my simple grid. I couldn't find something close to my situation but there must be an easy way to accomplish this.
Posted
Updated 8-Jul-16 14:32pm

1 solution

for what I've understood it seems like you want see if something changed or not so if this is it then this is what you should do:
first you have to create string that contains the "old" thing(like text) and the new string
Now put the information in one textbox from the database(I'm assuming you know how to do it, if i'm wrong then use this code:
VB
Dim Str As String
Try
   Str = "update tabel1 set ID="
   Str += """" & TextBox1.Text & """"
   Str += " where ID="
   Str += TextBox1.Text.Trim()
   provider.Open()
   Cmd = New OleDbCommand(Str, provider)
   Cmd.ExecuteNonQuery()
   provider.Close()
   Catch ex As Exception
End Try

)
VB
public sub Form1
dim Str_Old As String
dim Str_Old As String 

Then to use those is as easy as :
VB
Private Sub Form1 (...) handles Form1.load
Str_Old = TextBox1.Text ' Original data like if you have the things loading on startup to a textbox

Private sub Check_Changed
StrNew = TextBox1.Text
if Str_New <> Str_Old then ' The "<>" means different
' Your code here (The one that is suposed to act if something changed)
Else
' Your code here (The one that is suposed to act if nothing changed)
End If

Now to call this is easy if you want this to act when a button is pressed then just put this into the button:
VB
Check_Changed()

Now you are good to go
Disclaimer: I just explained everything step-by-step because you say you are a beginner.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900