Home Get/Set current UserID Getting started

From .NET code

Use DataInterface.SetCurrentUserID, as demonstrated in the following code sample. For more information, see the documentation.


    using (SqlConnection conn = new SqlConnection(strConnectionString))
    {
        conn.Open();
        DataInterface.SetCurrentUserID(conn, UserID);

        //Perform your command here
    }


From native SQL

Use the procedure SetCurrentUserID, and the function CurrentUserID, as demonstrated in the following code sample.

    
    --Set UserID
    exec SetCurrentUserID @UserID
    
    --Find UserID
    SELECT dbo.CurrentUserID()