View Full Version : Changed textbox to DropDown in Login

07-20-2004, 04:15 PM
I changed my login page to have a drop down of users and text box for the password. I have the page created where both fields are text boxes and that works fine. However, when i add a drop down and change the txtusername.text to txtusername.selecteditem.text, the page doesn't seem to work completely. If the user types in the wrong password, the "invalid password' prompt appears, but if you enter the right password, it does not take you to the next page. The page simply refreshes. Can anyone find the problem here?

Sub button_Click (s As Object, e as EventArgs)

If IsValid Then

Dim IntUserID as Integer

IntUserID = DBAuthenticate(txtusername.text, txtPassword.text)

Select Case IntUserID

Case -1

LblMessage.text = "Non existent user"

Case -2

LblMessage.text = "Invalid Password"

Case Else

Session("Regionid") = IntUserID

Session("RegionName") = TxtUsername.text


End Select

end If

End Sub

Sub button_Click2 (s As Object, e as EventArgs)


End Sub

Function DBAuthenticate (strUsername As String, strPassword As String) As Integer

Dim conMyData As SqlConnection

Dim cmdSelect As SqlCommand

Dim ParmReturnValue As SqlParameter

Dim intResult as Integer

conMyData = New SqlConnection("Server=localhost;UID=User;PWD=pw;Database=db")

cmdSelect = New SqlCommand ("DbAuthenticate", conMyData)

cmdSelect.CommandType = CommandType.StoredProcedure

parmReturnValue = cmdSelect.Parameters.Add( "return_value", SqlDBType.int)

parmReturnValue.Direction = ParameterDirection.ReturnValue

cmdSelect.Parameters.add("@Username", strUserName)

cmdSelect.Parameters.add("@password", strpassword)




intResult = cmdSelect.Parameters("return_value" ).value

Return IntResult

End Function