Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 12th, 2004, 11:21 PM
Authorized User
 
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to know who edit add records?

hi guys,

i have column in my table for username and updtime ,i want to save the login name and date.time of this user if he edit/add a row in my table
how can i do it?
windows2003 ,security integrated with sql2000
m using vb.net

  #2 (permalink)  
Old October 13th, 2004, 12:48 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

Have a field for all and keep updating on the even.

at the Insert option u keep the field value as "A" and for edit as "E" and for delete "D".

Also filed like userID, updtDate, updtTime as to be updated on event.


Gokulan Ethiraj
  #3 (permalink)  
Old October 13th, 2004, 12:52 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

This could be a useful tip :
http://p2p.wrox.com/topic.asp?TOPIC_ID=20561

Gokulan Ethiraj
  #4 (permalink)  
Old October 13th, 2004, 01:16 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Gokulan Ethiraj,

tnx for reply but it doesnt solve my problem, can u pls elaborate more, or do u have any other suggestion,

waiting for ur help:)

  #5 (permalink)  
Old October 13th, 2004, 02:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

How do you pick the login name? Is that the login that is used to connect to sql server or the one used in frontend app to get updated on to that table?

If you are looking to do that from the backend, then...
You may update the columns for username with the login info that comes along when the user tries to update and use getdate() for the other column that denotes update time. I don't see this done easier at the backend as the login information has to come from the frontend.

So I suggest, if you are looking for help related to doing that using VB.net, you may probably post that on a relavant .net forum here. This is SQL server related forum and not .Net.

Cheers!

_________________________
- Vijay G
Strive for Perfection
  #6 (permalink)  
Old October 13th, 2004, 02:08 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok, i see ur point, tnx anyway

  #7 (permalink)  
Old October 13th, 2004, 03:43 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

additional

SUSER_SNAME(), - get windows login name

adding this to your column 'username' will default to use name who has log in to using windows authentication

Jaime E. Maccou
Applications Analyst
  #8 (permalink)  
Old October 13th, 2004, 03:50 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default


hi jaime,

SUSER_SNAME(), - get windows login name

adding this to your column 'username' will default to use name who has log in to using windows authentication

sorry i really cant understand what u mean,
how do i use SUSER_SNAME(), in select statement? or pls elaborate
tnx for ur help,
waiting for ur respnse

  #9 (permalink)  
Old October 13th, 2004, 04:14 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Please noticed change to spelling of user name.

SUSER_SNAME() is built in to SQL Server

1.You can use it by adding SUSER_SNAME() as a default for your table column default value.

2. using a select statement - SELECT SUSER_SNAME()

Example:
say you have columns

orderid
orderdate
Requireddate
username

select orderid,orderdate,requireddate,SUSER_SNAME()as username
from orders




Jaime E. Maccou
Applications Analyst
  #10 (permalink)  
Old October 13th, 2004, 04:28 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

tnx jaime :)
now i understand it, I'll try this tommorow in my ofc to run ur code,I'll update this to you what happen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit records problems Indo77 Classic ASP Databases 0 August 11th, 2005 09:35 AM
Edit or Delete records tsimsha Classic ASP Basics 6 October 30th, 2004 03:26 AM
how to know who edit or add records? drachx General .NET 1 October 13th, 2004 05:36 AM
How to add edit records in .dbf file cbpanchal VB Databases Basics 1 July 7th, 2004 11:14 PM
How to add edit records in .dbf file cbpanchal VB How-To 2 June 25th, 2004 01:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.