Page 1 of 2

SQL Backend - Capture users details

Posted: 13 May 2009, 12:27
by Tribble
I need to be able to capture the user's details (name) every time they edit a record in a table. I would also like the date and time.

We now have a few users that are deleting information in fields. We need to be able to track who the idiot is and deal with them. The data is stored in SQL tables. Is there a way that I can build it into SQL or do I have to do it through a Query in Access?

This is rather urgent as we need to sort this out asap. Most users are using Windows authentication to log in.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 08:35
by RuadRauFlessa
Tribble wrote:I need to be able to capture the user's details (name) every time they edit a record in a table. I would also like the date and time.

We now have a few users that are deleting information in fields. We need to be able to track who the idiot is and deal with them. The data is stored in SQL tables. Is there a way that I can build it into SQL or do I have to do it through a Query in Access?

This is rather urgent as we need to sort this out asap. Most users are using Windows authentication to log in.
You could turn transaction loggin on but seing as you are using Acces and not SQL Server I doubt it is possible. I would say work it into the queries.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 09:10
by Tribble
I will look into that. Working on the forms rather as queries seem more complex.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 09:18
by RuadRauFlessa
Tribble wrote:I will look into that. Working on the forms rather as queries seem more complex.
:lol: depends on the queries.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 09:23
by Tribble
I have queries based on queries that are based on queries

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 09:26
by RuadRauFlessa
Tribble wrote:I have queries based on queries that are based on queries
Then consolidate them. I know it is a big job but the simpler the better.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 09:49
by rustypup
just to toss my dodgy penny into the pot... when users are deleting critical data, this says "design flaw" - time to relook the input approach.

User Level Security - i'm no access fundi, but you should be able to prevent unauthorised deletion ...

after a brief scan, it would appear that user logging and user object references are only available once ULS is installed, not before then.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 09:56
by Tribble
The problem is the user we suspect of deleting data is the one who is supposed to have full access rights. She is not deleting complete records - just clearing out fields. She does leave some data but many of the fields are wiped clean. Not sure how she is doing this accidentally as it involves going into each field and pressing delete or space. She then says that as the record was added last year - she could really not have deleted the data. I need to track who was the last to edit a record and the date and time of that edit.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:20
by doo_much
OK I am a total SQL n00b so see this as a question!

Is it not possible to create and UPDATE trigger within the SQL table? Code the trigger so that it
  • 1. Creates a 'back-up of the deleted data
    2. Captures the users' info etc?
As I said - question

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:27
by RuadRauFlessa
doo_much wrote:OK I am a total SQL n00b so see this as a question!

Is it not possible to create and UPDATE trigger within the SQL table? Code the trigger so that it
  • 1. Creates a 'back-up of the deleted data
    2. Captures the users' info etc?
As I said - question
Problem is that when you use a trigger you don't know who the user was that made the change to the record. Also I am not 100% sure if you can add triggers to tables in Access.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:32
by doo_much
RuadRauFlessa wrote:
doo_much wrote:OK I am a total SQL n00b so see this as a question!

Is it not possible to create and UPDATE trigger within the SQL table? Code the trigger so that it
  • 1. Creates a 'back-up of the deleted data
    2. Captures the users' info etc?
As I said - question
Problem is that when you use a trigger you don't know who the user was that made the change to the record. Also I am not 100% sure if you can add triggers to tables in Access.
Tribble wrote:The data is stored in SQL tables.
:D

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:32
by doo_much

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:39
by Tribble
Oooh thank you - I will have a look at that.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:42
by rustypup


SQL is a language...

SQL Server is a platform

MS Access, (with its own flavour of SQL), does provide some of this functionality, but only if USL is installed - without it, there is no reference to the editing user, (although i haven't dug to deep)

from my very sketchy knowledge, access does allow triggers, and runs a rollback instance for each session - perhaps have a trigger trap, inspect and rollback the essential fields... :?

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:42
by RuadRauFlessa
In that case go and create 4 triggers for each table in your SQL DB

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:44
by mina.magpie
I coded something similar in SQL Server a few years back in a project. Basically I used the database itself to do user validation so I could track who was doing what, and then mirrored every user action into a log table. IDK if it will translate well to Access since I don't know what its limitations are compared to Server, but if you want I can email you the code and you can see if there's anything in there you could use. I could also probably talk you through it on chat or something, if you want.

Mina.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:45
by doo_much
rustypup wrote:


SQL is a language...

SQL Server is a platform
Ahh Thanks!

and thank goodness for my n00bness disclaimer!

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:46
by Tribble
ROTFL - never.

It is going to be easier to write a function in the forms that captures the date and time and user's name. Besides - my SQL programming knowledge is non existent. I am still struggling with VBA as it is :lol: :lol: :lol:

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:49
by rustypup
mina.magpie wrote:I used the database itself to do user validation so I could track who was doing what
SQL is already doing all of this... those monster logs are there for a reason, (SQL actually uses these logs for many rollback actions...)

access is server's 'special' cousin, twice removed...

i still say the design is flawed. a proper, coded, front-end is the preferred approach to data capture. no user should be entering data directly into a production database using forms. ever. it's just begging for precisely this sort of issue...

now all we need to hear is "there are no backups" and i run screaming for the hills... :lol:

@Tribble - have you considered a coded front-end?

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:52
by mina.magpie
Tribble wrote:It is going to be easier to write a function in the forms that captures the date and time and user's name. Besides - my SQL programming knowledge is non existent. I am still struggling with VBA as it is :lol: :lol: :lol:
Cool beans. As long as you can be sure your user-base only has access to the db via your forms application, you could easily just pipe it all into a text file. If you do end up requiring something more robust though, just shout. :)

Mina.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:56
by rustypup
it would appear access!=triggers, so there goes that option... time to bite the bullet :twisted:

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:57
by RuadRauFlessa
rustypup, Yeah but she only uses Access as a front end with the forms it provides. They use a SQL Server 2005 SP1 for the back end where the data is actually maintained.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 10:59
by Tribble
rustypup, I really have no idea what you mean by a coded front end. I have a users table which controls access and rights to the database. The SQL server also controls who is allowed to access the database and what rights they have. They use their Window's Authentication. I have three people who have to be allowed to add, edit, delete. I am the only one that can create. There are others that have viewing rights only.

The problem is - one of the three people is causing the problems we have. I need to work out which one so that we can prevent further problems.

We do daily backups which are kept for 14 days. We also do monthly backups and those are kept for 3 months. All are offsite.
no user should be entering data directly into a production database using forms. ever. i
What do you mean by this? How can we update the certifications of the brokers if we cannot edit their data? How can we add new employees - check their supervision requirements if we cannot add the required information? You have me very confused puppy.

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 11:04
by RuadRauFlessa
Tribble wrote:rustypup, I really have no idea what you mean by a coded front end. I have a users table which controls access and rights to the database. The SQL server also controls who is allowed to access the database and what rights they have. They use their Window's Authentication. I have three people who have to be allowed to add, edit, delete. I am the only one that can create. There are others that have viewing rights only.

The problem is - one of the three people is causing the problems we have. I need to work out which one so that we can prevent further problems.

We do daily backups which are kept for 14 days. We also do monthly backups and those are kept for 3 months. All are offsite.
no user should be entering data directly into a production database using forms. ever. i
What do you mean by this? How can we update the certifications of the brokers if we cannot edit their data? How can we add new employees - check their supervision requirements if we cannot add the required information? You have me very confused puppy.
What he means is that you should have an application which does data integrity checks. Although SQL Server already caters for foreign indexes you should still check weather the data entered is acceptable. Say you have a description field and someone tries to update the said field you have to check that the new data entered for the field is not blank/zero length/spaces

Re: SQL Backend - Capture users details

Posted: 14 May 2009, 11:18
by Tribble
I have that already - it doesn't help if they accidentally replace data with a space. But we cannot refer to the old data in order to control the new. One chap moves from one Province to the other, to a different region or branch. We need to be able to capture the data - no matter whether it is completely different to what was there before or not.

How do you prevent spaces from being added?