Note:
Stored Procedures can prevent the threat of SQL Injection Vulnerabilities and are very secure. The Stored Procedure contains input and output parameters. The input parameters include the user ID and password. The returned values indicate different results.
Alter procedure [DBO]. [logining] (@ in_id varchar (10), @ in_password varchar (10), @ out_parameter varchar (10) Output) /** @ in_id input parameter ID @ in_password input parameter password @ out_parameter outgoing parameter 0 success/1 Password error/2 Current Status unavailable or other reasons */asdeclare @ temp_password varchar (10 ); declare @ temp_status varchar (10); declare @ temp_blog varchar (10); declare @ temp_event varchar (100); declare @ temp_count int; select @ temp_count = count (*) from users where id = @ in_id; select @ temp_password = password from users where id = @ in_id; select @ temp_status = status from users where id = @ in_id; set @ temp_event = 'Log On to the system client'; -- verify that the password is correct if (@ temp_count <1) set @ out_parameter = 3; else beginif (@ temp_password = @ in_password) begin -- verify whether the status is available if (@ temp_status = 1) beginset @ out_parameter = 0; Exec writeblog @ in_id, @ temp_event, @ temp_blog output; endelsebeginset @ out_parameter = 2; endendelseset @ out_parameter = 1; End