Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1910
UserName as Parameter
posted

I am using the UltraWebGrid and want to track who is making a change to the data. I am using stored procedures for my select, insert, update and delete commands in the grid. When someone updates a record, I would like to send the username (current user logged in) to the stored procedure so that it can be updated in the table, but I can't figure out how to send the username as a parameter. Any help is appreciated. Thanks!

  • 1910
    Offline posted

    Hmmm...even when I change it so that the SQLSataSource uses SQL statements instead of stored procedures, I still can't seem to figure out how to send the UserName.

    My code looks like this right now: INSERT INTO tblLookup_Diag_Codes_CHF(Diag_Code) SELECT Diag_Code = @Diag_Code

    but I want it to look like this: INSERT INTO tblLookup_Diag_Codes_CHF(Diag_Code, Inserted_By) SELECT Diag_Code = @Diag_Code, Inserted_By = @Inserted_By

    except I need the @Inserted_By to be the login of the user that is currently logged in.

     

  • 45049
    Suggested Answer
    posted

    Adding an additional parameter to a SQL statement would be done independently of WebGrid.

    My advice is to add a parameter to your INSERT and UPDATE commands, to transmit the user's username.  MSDN is likely to be a better resource for determining how to do this.  Here's one article from MSDN that may help get you started, if you're using a SqlDataSource control:
    Using Parameters with the SqlDataSource Control