如何将应用程序用户名保存到数据库表? [英] How do i save application user name to database table?

查看:109
本文介绍了如何将应用程序用户名保存到数据库表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划如下附加应用程序用户名和连接字符串

I am planning to attach the application user name along with the connection string as follows

Application Name=MyApplicationUserName;Data Source=ServerName; Initial Catalog=DatabaseName; Integrated Security=SSPI; 


这样我可以设置默认值,而不是从前端发送它


So that I could set up default value rather than sending it from the front-end

CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
InsertedBy varchar(255) DEFAULT  APP_NAME()
)


请告知是否还有更好的方法.

预先ThanX


Please advise if there''s any better way of doing it.

ThanX in advance

推荐答案

CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName nvarchar(255) NOT NULL,
FirstName nvarchar(255),
Address nvarchar(255),
CreatedBy int,
CreatedOn datetime DEFAULT getdate(),
UpdatedBy int,
UpdatedOn datetime 
)




通过这样做,您可以跟踪用户(当多个用户有权访问同一页面时)是否更新.


问候,
灰烬




By doing this you can track the user (when multiple user have access to the same page) if it gets updated.


Regards,
Ashish


这篇关于如何将应用程序用户名保存到数据库表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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