ASP storage process (SQL version ASP Invoke stored procedure) _asp Foundation

Source: Internet
Author: User
Storage process (SQL sample version)
I'm sending you a SQL storage process today.
Copy Code code as follows:

CREATE PROCEDURE login_verify

(
@community_id int,--Take value
@username varchar (20),
@password varchar (40),
@result tinyint output
)

As

SET NOCOUNT ON


Declare @service_deadline_date smalldatetime, @community_setting_max_online_count int---defines a variable as a short date format

Select @community_setting_max_online_count =community_setting_max_online_count, @service_deadline_date =service_ Deadline_date from Community_info where community_id= @community_id--This is the maximum number of logins

If DateDiff (d, @service_deadline_date, GETDATE ()) >10-In fact, this is to limit the user's usage period, the current date and the record date in the library is greater than 10 days, then return @result =11
Begin
Set @result = 11--Exceeds the usage period
Return
End


if (select COUNT (*) from online_user where = @community_setting_max_online_count ">community_id= @community_id) >= @community_setting_max_online_count--Compare the current number against the record set in the library
Begin
Set @result = 10-Exceeds online number limit-returns @result=10
Return
End


declare @stamia int, @last_update_stamia_date smalldatetime, @level_id INT--Define variable integer short date type integral type
declare @userid int, @user_role int
Select @userid =userid, @user_role =user_role, @stamia =stamia, @last_update_stamia_date =last_update_stamia_date,@ level_id=level_id from User_info where Username= @username and password= @password and community_id= @community_id and user _type=0

--From the User information table, write some information into the three variables defined

If @userid is not null----if @userid invariant null value
Begin-User name and password checksum success
Set @result = 1-Test success
Return
End
Else
Begin
Set @result =0---login failed
End

SET NOCOUNT OFF

Go

We'll take a name for the process above, called login_verify.

Written as a place to invoke security authentication in ASP code

"The conn has been defined beforehand.

Set cmd. Activeconnection=conn
cmd.commandtext= "Login_verify"
cmd.commandtype=&h0004

@community_id int,--Take value
@username varchar (20),
@password varchar (40),
@result int

Cmd. Parameters.Append cmd. CreateParameter ("@community_id", 3)
Cmd. Parameters.Append cmd. CreateParameter ("@username", 200)
Cmd. Parameters.Append cmd. CreateParameter ("@password", 200)

CMD ("@community_id") =session ("community_id")
CMD ("@username") =request ("userid")
CMD ("@password") =request ("userid")

Cmd.execute

Dim result

Result=cmd ("@result")

Conn.close

If trim (Result) = "1" Then


"" "" "" "" "" "" sign and action of success

Else

' ' ' "'" ' "'" ' "'" ' "'" ' "'" ' "

End If




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.