Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Client Info

Status
Not open for further replies.

itsmarkdavies

Programmer
Joined
May 22, 2001
Messages
87
Location
GB
I am using Visual Basic 6 to call a SQL Server 2000 Stored
Procedure from a client PC machine.

When the Procedure runs I want to log who called it in a Table on the Server.

How do I capture the details of the client PC ?

Thanks.
itsmarkdavies@hotmail.com
 
You could accomplish this in a several different ways. Check out @@CURRENT_USER in SQL.... and you can use a couple of different API calls if you want to pass it from the front-end.


Private Sub Form_Load()
Dim i As Integer

i = 1
Do While (Environ$(i) <> &quot;&quot;)
Text1 = Text1 & i & &quot; = &quot; & &quot;&quot;&quot;&quot; & Environ$(i) & &quot;&quot;&quot;&quot; & vbCrLf
i = i + 1
Loop
Text1 = Text1 & &quot;COMPUTERNAME = &quot; & &quot;&quot;&quot;&quot; &
Environ$(&quot;COMPUTERNAME&quot;) & &quot;&quot;&quot;&quot; & vbCrLf
Text1 = Text1 & &quot;USERNAME = &quot; & &quot;&quot;&quot;&quot; & Environ$(&quot;USERNAME&quot;) & &quot;&quot;&quot;&quot;
& vbCrLf
End Sub
 
Hi,

I wrote an SP to find the hostname for a particular user... i hope this is what u want.

CREATE PROCEDURE username AS
declare @username as varchar(230)

Select @username = suser_sid()
select top 1 hostname from master..sysprocesses where sid = suser_sid() order by spid desc

GO

Sunil
 
What details do you need?

You can get the host name using the SQL system function HOST_NAME(). You can get the login with the system function SYSTEM_USER.

You can insert these into the log table or set the default value of the coulmns to the functions and SQL will insert the value when a row is inserted in the table. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top