Last post Aug 22, 2019 03:16 AM by Yuki Tao
Aug 21, 2019 12:38 PM|sssaa|LINK
Hi, I want to ask how when a user logs on to his system, only his data is displayed. I've created a login page, but it displays all the information available to me, and I only want it to be displayed as information from a table to which other tables
are linked via fk key.
Aug 21, 2019 01:01 PM|PatriceSc|LINK
Unclear. A login page usually doesn't show anything but just let the user to enter his id/password. Do you mean once logged, you are missing a WHERE clause in a SQL query ? Usually you get the user identifier for the authenticated user (though the User.Identity.Name
property of your controller or some other identifier claim and use that to filter out which info should be shown.
Edit: or for now your site doesn't even have any authentication option ? Which authentication method are you using?
Aug 21, 2019 02:06 PM|sssaa|LINK
Being logged in does not mean anything, but how to get everyone to log in and if its ID matches the main table as well as the other IDs and show them to me If there is any example where 2-3 tables are linked because I only find examples where there is 1
Aug 21, 2019 02:07 PM|mgebhard|LINK
This is a database design question. The userId must be linked to records that belong to the user. Then simply filter the result set by the user ID.
We cannot see your table design so there is no way to provide any kind of solution. At this point it seems like you need to rethink the table schema.
Aug 21, 2019 08:17 PM|bruce (sqlwork.com)|LINK
this is called horizontal partitioning. all the users data rows needs a column that identifies which user it belongs to. you then include this column value in a where clause for all queries.
another approach is to use a document database, and have the documents keyed by user.
Aug 22, 2019 03:16 AM|Yuki Tao|LINK
but it displays all the information available to me, and I only want it to be displayed as information from a table to which other tables are linked via fk key.
The content displayed on the page depends on what statement you passed to the page in the action.
You need to filter you data by some linq,such as: where(),groupby()...e.g.
I suggest you could add breakpoints on your code and select your query SHIFT+F9 to quick watch its value and modify.