Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to retrieve ip address using sql server 2000

Author  Topic 

DURGESH
Posting Yak Master

105 Posts

Posted - 2008-10-13 : 07:44:53
hi all,
i want to insert a record in tbl along with ip address info

can anybody help me to solve this issue


thanks in advance

Regards
Durgesh J

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-13 : 07:46:23
Ip address info is taken from where?
Client? server? other?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

DURGESH
Posting Yak Master

105 Posts

Posted - 2008-10-14 : 05:00:40
hi
from client machine
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-14 : 05:13:32
Send the client IP address as a parameter to the stored procedure.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

DURGESH
Posting Yak Master

105 Posts

Posted - 2008-10-14 : 05:17:49
hi peso,
i want to enter a record in a table whenever a client perform some
DML operation along with ip address of his machine

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-14 : 05:23:46
You want some logging on specific tables?

How about you describe your scenario (what you want to do), including your problem, with plain english?
Then we may be able to help.

Getting only fragments of your full problem is NOT helpful.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

DURGESH
Posting Yak Master

105 Posts

Posted - 2008-10-14 : 05:35:11
hi peso,
i want to know the client who had performed delete,insert,update operation on tables
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-14 : 05:41:28
In SQL Server 2000 you must create an AFTER TRIGGER on each of the tables you want to log.
You can use GETDATE() and SUSER_SNAME() for example to log which user did what and when.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-10-14 : 05:48:38
I have one used this to get the ip information if that is any help, and then you could enclose this in a trigger with an added insert statment at the bottom perhaps

Declare @ipLine varchar(200)
Declare @pos int
Declare @ip varchar(30)
set nocount on
set @ip = NULL

Create table #temp (ipLine varchar(200))

Insert #temp exec master..xp_cmdshell 'ipconfig'

select @ipLine = ipLine
from #temp
where upper (ipLine) like '%IP ADDRESS%'
if (isnull (@ipLine,'***') != '***')
begin
set @pos = CharIndex (':',@ipLine,1);
set @ip = rtrim(ltrim(substring (@ipLine ,
@pos + 1 ,
len (@ipLine) - @pos)))
end


Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-14 : 05:49:12
quote:
Originally posted by DURGESH

hi
from client machine



This is quite straightforward to implement in either classic ASP or .net ( vb.net or c#)

All depends on which front end you are using. Then you can easily pass it to the db

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-14 : 06:02:32
Neil, does the code snippet get the CLIENT ip-address or the server ip-address?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-14 : 06:14:47
Its best, DURGESH confirms which frontend he/she is using since. He wants the client's IP

It can be done with one line of code in either c# or classic ASP
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-14 : 06:23:28
In Classic ASP you use


IP = request.ServerVariables("REMOTE_ADDR")


in .net using c# you use


string IP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();


Then you can pass the variable to your database via your SP

Go to Top of Page
   

- Advertisement -