Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to store and retrieve users added to sql database using c#(Winforms) . When a user logs in to the application (C#), controls will be enabled/disabled/visible/hidden based on the role that the user has been added to and, logs will be stored when the user accesses a stored procedure, view or functions. My question is: Do I need to create a database user(sql database user) for each user name (using a single login name)
when the user of the c# application add a new user or do i create a database table and add users to it (using single login name and user name to sql database and server)?

What I have tried:

i do not know which option is suitable.
Posted
Updated 14-Sep-17 4:33am

1 solution

No, your app is the SQL User, the actual users should be stored in a table which is accessed via the single SQL User. You add and remove users (and their roles) to that table.

(If you think about it, that's the only sensible way to go, to create a user in SQL from your code, you'd need to connect to SQL - which requires a user with the right permissions.)
 
Share this answer
 
Comments
kwaku Emma 13-Sep-17 15:32pm    
how do I make log entries when user accesses stored procedures?
OriginalGriff 14-Sep-17 4:51am    
Do you want to try explaining that, assuming that I can't see your screen, access your HDD, or read your mind? :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900