Results 1 to 2 of 2

Thread: [RESOLVED] logon only if enabled

  1. #1

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Resolved [RESOLVED] logon only if enabled

    hi there,
    my login was working fine with only using the 2 fileds user name and password

    my login page uses my companydb.aspx code file to process the logins

    basically i want to upgrade the login if you like
    before it was
    username password correct then come on in
    if not correct stay out

    now i want

    if username password and comp_enabled = 1
    then come on in

    CompanyDB code
    VB Code:
    1. Public Shared Function ValidateUser(ByVal UserName As String, ByVal Password As String, [COLOR=RoyalBlue]ByVal enabled As String[/COLOR]) _
    2.             As Boolean
    3.  
    4.         Dim sSelect As String
    5.         sSelect = "SELECT COUNT(*) FROM tb_comp_detail " _
    6.                 & "WHERE c_companycode = '" & UserName _
    7.                 & "' AND c_password = '" & Password & "'" _
    8.                 [COLOR=RoyalBlue]& "' AND c_comp_enabled = '" & enabled & "'"[/COLOR]
    9.  
    10.         Dim cmdSelect As New SqlCommand(sSelect, Connection)
    11.         Dim iCount As Integer
    12.         cmdSelect.Connection.Open()
    13.         iCount = cmdSelect.ExecuteScalar()
    14.         cmdSelect.Connection.Close()

    my login page

    VB Code:
    1. Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    2.      
    3.         If companyDB.ValidateUser(txtUsername.Text, txtPassword.Text, [COLOR=RoyalBlue]lblOn.Text[/COLOR]) Then
    4.  
    5.             FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, chkAutomatic.Checked)
    6.         Else



    changes i made above are in blue

    the lblon is just a label text 1 in it

    the error i get is incorrect syntax near 1
    it works 60% of the time, all the time.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: logon only if enabled

    You have two ' characters after Password (one on each of the last two lines), you should only have one of them.

Posting Permissions

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



Click Here to Expand Forum to Full Width