locked
Using ASP.Net "UserName" as a Key in an SQL statement RRS feed

  • Question

  • I am using the built in ASP.net login feature. Once a user has successfully logged in, I would like to perform an SQL read into GRIDVIEW to load all the rows from a table I call tblShareholder which match the UserName.  Using the wizard I click on the "WHERE" button, choosing the "ShareholderUserName" column, and the "=" operator. My question is -How do I use the ASP.net "UserName" variable as the "Source" entryand are there any "Parameter" entries?
    • Moved by Kristin Xie Wednesday, August 5, 2015 3:16 AM MVC related
    Tuesday, August 4, 2015 12:48 PM

Answers

  • Please post asp.net question at the asp.net forum for a better assistance on your case.

    Fouad Roumieh

    • Proposed as answer by Just Karl Wednesday, August 5, 2015 4:44 PM
    • Marked as answer by Just Karl Friday, September 4, 2015 9:59 PM
    Tuesday, August 4, 2015 12:50 PM
  • In addition to that, why use the Username? You got a proper primary key for that User table and it is not the Username (unless somebody really failed at DB design, in wich case you should change that ASAP).
    When creating a session, the Users Primary Key should be part of that session. Not the name. Same with every kind of data you way to store (who posted wich post). The name is just a string, strings should not matter.
    If you want to unambigiously identify a tupel in another table, always use the primary key. And avoid using string as a primary key, except for very special cases.

    • Edited by Christopher84 Tuesday, August 4, 2015 1:49 PM
    • Proposed as answer by Just Karl Wednesday, August 5, 2015 4:45 PM
    • Marked as answer by Just Karl Friday, September 4, 2015 9:59 PM
    Tuesday, August 4, 2015 1:49 PM

All replies

  • Please post asp.net question at the asp.net forum for a better assistance on your case.

    Fouad Roumieh

    • Proposed as answer by Just Karl Wednesday, August 5, 2015 4:44 PM
    • Marked as answer by Just Karl Friday, September 4, 2015 9:59 PM
    Tuesday, August 4, 2015 12:50 PM
  • In addition to that, why use the Username? You got a proper primary key for that User table and it is not the Username (unless somebody really failed at DB design, in wich case you should change that ASAP).
    When creating a session, the Users Primary Key should be part of that session. Not the name. Same with every kind of data you way to store (who posted wich post). The name is just a string, strings should not matter.
    If you want to unambigiously identify a tupel in another table, always use the primary key. And avoid using string as a primary key, except for very special cases.

    • Edited by Christopher84 Tuesday, August 4, 2015 1:49 PM
    • Proposed as answer by Just Karl Wednesday, August 5, 2015 4:45 PM
    • Marked as answer by Just Karl Friday, September 4, 2015 9:59 PM
    Tuesday, August 4, 2015 1:49 PM