1
Answer

sql server connection to login form created in asp.net and c

kritika Rana

kritika Rana

12y
1.8k
1
hi

I have created a login page and a table in sql server using windows authentication and a stored procedure to insert the values from login form

But when I click on the login button it shows the following error

Server Error in '/WebSite1' Application.

Login failed for user 'vikas-PC ikas'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'vikas-PC ikas'.
[SqlException (0x80131904): Login failed for user 'vikaskriti'.]



My connection string is as follows--------->>>>


  string strcon = "Data source= -.; User id=vikas-PC\vikas; initial catalog =master";

Please help me in resolving the above error

Thanks
kritika Rana
Answers (1)
0
Rahul Kaushik
NA 383 14.6k 7y
There is a perfect way while using flag to detect whether someone is already logged in or not and in case if System get power off , you need an event handler called as SystemEvents.SessionEnds.
 
Use this to change the flag value from true to false
 
Use this link as a reference
https://stackoverflow.com/questions/6799955/how-to-detect-windows-shutdown-or-logoff 
0
Mann Maurya
NA 47 867 7y
Hey Ajeesh
 
one more question... ??
 
If power off happen then how you suppose to Reset the flag
 
0
Ajeesh
NA 349 1.6k 7y
You can take a look at this article which discuss a similar topic. 
 
https://blog.learningtree.com/preventing-duplicate-logins-in-asp-net/
 
Another option would be to have a flag in your table and set the value to true when an user login and when user log off set the value to false.  Also for when a second user tries to login we will first check if login flag has been set to true for any other user. If its true then show message to user and display the login page, if not allow the user to login.