我刚刚制作了一个脚本来借助c#检测客户端IP地址。现在我只想从sql server处理。使用定标器值功能。从存储过程中执行此功能,如:
USE [NEWBULKSMS]
GO
/****** Object: StoredProcedure [dbo].[BulkSMS_ViewUsercompanyProfile] Script Date: 29/11/2019 5:07:22 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[BulkSMS_ViewUsercompanyProfile](
@pId INT
)
AS
BEGIN
BEGIN TRY
SELECT *
FROM companyprofile
where Userid = @pId;
--Insert LastLoginDateTime DateTime
update users
set [dtlastlogin] = GETDATE()
where ID =@pId
--End DateTime
--Get IP Adresss
INSERT INTO [dbo].[login_log]
([user_id]
,[date_time]
,[ip_add]
,[detail])
VALUES
(@pId
,getdate()
,<ip_add, nvarchar(50),> -- here i just want ip address from client side
,<detail, nvarchar(100),>)
--Ip Address
END TRY
BEGIN CATCH
EXEC [dbo].[usp_LogErrorHistory];
DECLARE @err VARCHAR(MAX)
SELECT @err = ERROR_MESSAGE()
RAISERROR('Error while getting : [dbo].[BulkSMS_ViewUsercompanyProfile]', 16, 1, @err)
END CATCH
END