确定谁连接到应用程序

编程入门 行业动态 更新时间:2024-10-25 00:32:26
本文介绍了确定谁连接到应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找一种确定谁连接到Windows应用程序的方法.首先,我查看了连接到sql服务器的用户,但我读到的内容仅显示活动用户.因此,我想我需要一种在用户登录表时存储用户名,但在用户注销时将其删除的方法. 我最终将要将此信息放入列表框或datagridview 我知道ENVIRONMENT.USERNAME,但不确定如何执行此操作.

I am looking for a way to determine who is connected to my windows application. First I looked at who was connected to the sql server but I read that will only show active users. So I guess I need a way to store the username when they log in into a table but remove it when they log off. I will eventually want to put this information into a listbox or datagridview I know ENVIRONMENT.USERNAME but not sure how to do this.

推荐答案

AFAIK Environment.UserName仅向其运行的特定计算机上的操作系统用户提供权限. (不知道那里发生了什么,中途中断了) 因此,您的程序可以调用Environment.UserName或My.User.Name并将该信息发送到数据库,该数据库可以存储计算机名称,用户名和时间. (这真是第二次很奇怪) 然后在OnFormClosing事件处理程序中再次调用它,并将其发送到可以存储注销时间的服务器. 可能有比这更好的解决方案,但这应该可行. AFAIK Environment.UserName only gives the User of the Operating System on the particular machine it runs on. (Don''t know what happened there, got cut off mid-stream) So your program could call Environment.UserName or My.User.Name and send that information to the database where it could store the Machine Name, User Name and Time. (This is really odd 2nd time) Then in the OnFormClosing event handler call it again and send that to the server where the logout time can be stored. There is probably a better solution than this but this should work.

更多推荐

确定谁连接到应用程序

本文发布于:2023-11-23 14:14:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621733.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   应用程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!