?
Solved

Need help with saving saving syscreator and sysmodifier on records how as been change added?

Posted on 2011-09-18
3
Medium Priority
?
241 Views
Last Modified: 2012-05-12
I want to add some logging code to records that has been change or added.

I've add the followings fields to my tables

Syscreator - int
Syscreated - datetime
Sysmodifier - int
Sysmodifed -datetime

How can i automatic update all records with this info if there is something added or changed.

I user vb.net and a SQL server.

On form close I check if the is something changed or added or deleted.

Hope to here from somebody!

Bart
0
Comment
Question by:prinsbj
[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
3 Comments
 
LVL 15

Accepted Solution

by:
x77 earned 2000 total points
ID: 36556697
If you have a DataTable, you can do:

  For Each Row As DataRow In MyTable.Rows
      If Row.RowState = DataRowState.Added Then
         'Log - Added Row
         'Set Syscreator ,Syscreated ,Sysmodifier ,Sysmodifed
      ElseIf Row.RowState = DataRowState.Modified Then
         'Log - Modified Row
         'Set Sysmodifier ,Sysmodifed
      End If
  Next

Do it Before DataAdapter.Update
Note. You can do it with  DataBase.Triggers, but I am not expert on SqlServer.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36570432
Are you using DataAdapters to update the DB? If so, use the RowUpdating event

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.rowupdating.aspx

0
 

Author Closing Comment

by:prinsbj
ID: 36593537
It works great!

Thank you.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 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