Need guidance in rewriting my ASP

Results 1 to 2 of 2

Thread: Need guidance in rewriting my ASP

  1. #1
    Join Date
    Dec 1969

    Default Need guidance in rewriting my ASP

    I have created a new stored procedure to authenticate my login page. Here&#039;s the SP: <BR><BR><BR><BR><BR>CREATE PROCEDURE DBAuthenticate<BR><BR>( <BR><BR> @UserName nVarChar (20), <BR><BR> @Password nVarChar (20), <BR><BR> @ID varchar(4) OUTPUT,<BR><BR> @SomeVar INT OUTPUT<BR><BR>) <BR><BR><BR><BR>AS <BR><BR>Declare @ActualPassword nVarchar (20) <BR><BR><BR><BR>Select @ID = RegionID, @ActualPassword = regpassword <BR><BR>From dbo.Regions<BR><BR>Where Region = @Username <BR><BR><BR><BR>If @ID is not null <BR><BR>Begin<BR><BR> if @Password &#060;&#062; @actualpassword <BR><BR> SET @SomeVar = -2<BR><BR>End<BR><BR>Else <BR><BR> SET @SomeVar = -1<BR><BR><BR><BR>RETURN<BR><BR>GO<BR><BR><BR><BR>< BR>Now this works properly, checking the userID and password. However, I need help rewriting my code to recognize these output parameters. Basically upon clicking my button, if the userID does not exist (@somevar = -1) "User does not exist" should display. If the password is invalid (@somevar=-2) then "Invalid password should be written. If the username and password match, then @ID is returned, and i want to save this ID as a session variable and redirect the user to the next page, aproval.aspx. Can anyone offer me help?? <BR><BR>Old Code:: <BR><BR><BR><BR><BR><BR>Sub button_Click (s As Object, e as EventArgs) <BR><BR>If IsValid Then <BR><BR>Dim IntUserID as String <BR><BR>IntUserID = DBAuthenticate(txtusername.text, txtPassword.text) <BR><BR>Select Case IntUserID <BR><BR>Case -1<BR><BR>LblMessage.text = "Non existent user" <BR><BR>Case -2 <BR><BR>LblMessage.text = "Invalid Password" <BR><BR>Case Else <BR><BR>Session("Regionid") = IntUserID <BR><BR>Session("RegionName") = TxtUsername.text <BR><BR>response.redirect(return_page) <BR><BR>End Select <BR><BR>end If <BR><BR>End Sub<BR><BR><BR><BR>Sub button_Click2 (s As Object, e as EventArgs)<BR><BR> response.redirect(back_page)<BR><BR><BR><BR>End Sub<BR><BR><BR><BR>Function DBAuthenticate (strUsername As String, strPassword As String) As String<BR><BR><BR><BR>Dim conMyData As SqlConnection <BR><BR>Dim cmdSelect As SqlCommand <BR><BR>Dim ParmReturnValue As SqlParameter <BR><BR><BR><BR>conMyData = New SqlConnection("Server=localhost;UID=Enr;PWD=no;Dat abase=no") <BR><BR>cmdSelect = New SqlCommand ("DbAuthenticate", conMyData) <BR><BR>cmdSelect.CommandType = CommandType.StoredProcedure <BR><BR>parmReturnValue = cmdSelect.Parameters.Add( "ID", SqlDBType.varchar, 4)<BR><BR>parmReturnValue = cmdSelect.Parameters.Add( "SomeVar", SqlDBType.varchar, 4)<BR><BR>parmReturnValue.Direction = ParameterDirection.ReturnValue <BR><BR>cmdSelect.Parameters.add("@Username", strUserName) <BR><BR>cmdSelect.Parameters.add("@password", strpassword) <BR><BR><BR><BR>conMyData.Open() <BR><BR><BR><BR>cmdSelect.ExecuteNonQuery() <BR><BR>Dim IdResult as string<BR><BR>conMyData.Close()<BR><BR>IdResult= CStr(cmdSelect.Parameters("ID" ).value)<BR><BR>Return IdResult<BR><BR>End Function<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Yet again: Cusoxty = Troll<BR><BR>does it just suck being you or what?<BR><BR>AT least show a little more effort in trying to hide your identity.... friggen dumb ****

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts