如何在审计触发器中使用system_user但仍使用连接池?
我想做以下两件事:
- 在我的数据库表上使用审计触发器来识别哪个用户更新了什么;
- 使用连接池来提高性能
对于#1,我在数据库触发器中使用“system_user”来识别进行更改的用户,但这阻止我执行需要通用连接字符串的#2。
有没有一种方法可以让我充分利用这两个世界?
ASP.NET/SQL Server 2005
I would like to do both of the following things:
- use audit triggers on my database tables to identify which user updated what;
- use connection pooling to improve performance
For #1, I use 'system_user' in the database trigger to identify the user making the change, but this prevent me from doing #2 which requires a generic connection string.
Is there a way that I can get the best of both of these worlds?
ASP.NET/SQL Server 2005
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很不幸的是,不行。 仅从数据库连接识别用户和在用户之间共享数据库连接是互斥的。
Unfortunately, no. Identifying the user just from the database connection AND sharing database connections between users are mutually exclusive.
将 Web 应用程序中的用户存储在数据库中,并让触发器触发存储的数据。 让 Web 应用程序处理将所有日志信息写入数据库可能会更好。
Store the user from your web application in the database and let your triggers go off that stored data. It might even be better to let the web app handle writing all logging information to the database.