Solved

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

Posted on 2011-09-18
3
238 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

697 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