简体   繁体   中英

Login Form Authentication C#

I create a stored procedure name sp_Auth and inside it is Table name UserAccounts with two fields, username and password both varchar(50) I declared two variables, @username,@password on stored procedure

Select * From UserAccounts where @username = username and @password = password

After I create it I put it into Linq to SQL together with the table and then I create new class to call the stored procedure from the linq to sql class.

My question is how do I make a method in order for the button in my login form to check or validate username and password typed in the textboxes to the data found on the table using my stored procedure.

I know there are a lot of ways on doing this but I found out they uses sqlcommand or something.

I need to use the class to call the stored proc.

The code I want to achieve is like this

Public static sp_Insert(Product p) db = new dataclass1context(); db.storedprocInsert(@Name,@Pname); Can I create a validator or checker in the class like the code above?

Take a look at Passing parameter to stored procedure . This will get you on the way. You can use the result of the query to determine if the user was validated.

Please keep in mind that passwords should not be stored as plaintext, and should be at least hashed and even salted, which would require you to convert the users password to the matching type of hash before your query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM