如何识别连接 [英] How to Identify Connection

查看:164
本文介绍了如何识别连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个用户使用插入SQL Server后端的Access前端。


我想要一些标识用户与SQL服务器会话的东西。


我试过@@ SPID并发现从同一个Access会话连接时可能有多个值。


同样,登录和用户名/ ID不可靠,因为完全可能有多个Access会话,这些需要被视为单独的会话。


有没有人有任何想法关于如何唯一地识别当前会话?

解决方案

我是用旧时尚方式做的。使用用户IP,连接日期和时间以及newid()生成我自己的会话ID。您可以将它从一个页面传递到另一个页面,然后检查服务器是否要继续进行连接,即。强制超时。不过,我只为内联网这样做。用户可能不希望看到我抓住他们的IP,即使我们都知道每次打开页面时都会发生这种情况:)


祝你好运!


~~ CK


当Access本身加载时,是否有办法为Access数据库生成一个随机整数?或者可能有一个SESSION表,当用户登录时,无论它是否是相同的用户名/密码组合,它都会创建一个带有随机生成ID的新记录,它将作为会话ID吗?


@CK这实际上是一种非常有创意的方式来生成会话ID,但是如果有很多open()/ close那么这也不会导致各种会话ID ()?

I have multiple users using an Access front end plugged into a SQL Server back end.

I want something that identifies the user''s session to SQL server.

I''ve tried @@SPID and found that there can be multiple values when connecting from the same session of Access.

Equally, login and user names/IDs are not reliable as it''s perfectly possible to have more than one session of Access going and these need to be treated as separate sessions.

Does anyone have any ideas on how I can identify the current session uniquely?

解决方案

I do it the old fashion way. Generate my own Session ID with the user IP, date and time of connection and a newid(). You can pass it from one page to another then do a check to the server if you want the connection to proceed ie. force timeout. I only do it for intranet, though. Users might not want to see I''m grabbing their IP, even if we all know it''s actually happening every time you open a page :)

Good Luck!!!

~~ CK


Would there be a way to generate a random integer for the Access database anytime Access itself loads? Or maybe have a SESSION table and when the user logs in, regardless if it''s the same username/password combination, it will create a new record with a randomly generated ID, which would act as the session id?


@CK That''s actually a pretty creative way of generating a session id, but wouldn''t that also cause various session id''s if there''s a lot of open()/close()?


这篇关于如何识别连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆