I am developing an application in Visual Studio 2003 .NET and using a SQL Server database backend.
I created a Trigger to monitor a table. When records are inserted into this table the Trigger will create an entry in an Audit table for reference. I am using the USER_NAME() function within the Trigger to try and capture the users WINDOWS NT LOGIN NAME. The Trigger is firing however the USER_NAME function is returning "dbo" instead of the users' WINDOWS NT LOGIN NAME.
In my application I am using the following to Insert the record.
Dim strSQL As String
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
strSQL = "......."
cnSQL = New SqlConnection(appOptions.ConnectionString)
cmSQL = New SqlCommand(strSQL, cnSQL)
How can I capture the user's WINDOWS NT LOGIN NAME?
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!