Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL stored proc and ASP calling code

Status
Not open for further replies.

SuperCyber

Programmer
Aug 10, 2001
35
US
Is there anyway to make this code run more efficient? I have added my APS calling code and the SQL stored procedure. Thanks for any help or input, it is very appreciated.

Brian

------------------ASP Code------------------
Dim cmdGetCust, varLogin, varPassword, strID, strFirstName, strLastName, strLogin

varLogin = Request("LOGIN_EMAIL")
varPassword = Request("LOGIN_PASSWORD")

Set cmdGetCust = Server.CreateObject("ADODB.Command")
With cmdGetCust
.ActiveConnection = connAPS
.CommandText = "sproc_CustLogIn"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@Login",adVarChar,adParamInput,50,varLogin)
.Parameters.Append .CreateParameter("@Password",adVarChar,adParamInput,50,varPassword)
.Parameters.Append .CreateParameter("@custID",adInteger,adParamOutput)
.Parameters.Append .CreateParameter("@custFirstName",adVarChar,adParamOutput,50)
.Parameters.Append .CreateParameter("@custLastName",adVarChar,adParamOutput,50)
.Parameters.Append .CreateParameter("@RETVAL",adInteger,adParamReturnValue)
.Execute
strLogin = .Parameters("@RETVAL")
strID = .Parameters("@custID")
strFirstName = .Parameters("@custFirstName")
strLastName = .Parameters("@custLastName")
End With


------------------SQL Stored Proc---------------
Alter Procedure sproc_CustLogin
@Login varchar(50),
@Password varchar(50),
@custID int = null OUTPUT,
@custFirstName varchar(50) = null OUTPUT,
@custLastName varchar(50) = null OUTPUT,
@RETVAL int = null OUTPUT
AS
DECLARE @chkPassword varchar(50)
set nocount on
-- Pull the record regardless of password
SELECT @chkPassword = custPassword
FROM tblCustomers
WHERE CONVERT(varbinary(50),custEmail) = CONVERT(varbinary(50),@Login)

IF @@ROWCOUNT > 0 --Found the login
BEGIN
SET @RETVAL =
CASE
WHEN CONVERT(varbinary(50),@chkPassword) = CONVERT(varbinary(50),@Password) THEN 3
ELSE 2
END

IF @RETVAL = 3
BEGIN
SELECT @custID = custID,@custFirstName = custFirstName,@custLastName =custLastName
FROM tblCustomers
WHERE custEmail = @Login
END
END
ELSE
BEGIN
SET @RETVAL = 1
END
RETURN @RETVAL
set nocount off
 
I'm curious about the conversion of the varchars before comparison.

I'm guessing that the asp asks for a different page for each retval?

A couple of superfluous (and probably just plain wrong) thoughts...

I prefer to write javascript (it's pretty easy to learn the basics which is all I know... But I have books!!) because some folks (like my son's school frinstance) use Netscape and vbscript she no run so good on it.

It think it would be more efficient to make COM servers. That way your code is compiled. 'Smatter of fact you've already written most of the code in your script. If you're really desparate and can find no more competent help than mine, I can show you how we do this where I work.



JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top