Vb Login ....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shreshta
    New Member
    • Sep 2007
    • 15

    Vb Login ....

    Hi ..

    I have a table which has user records and some other user details..table name is userdetails.

    My first page when the program runs is login. If the user enters right username..i.e existing username and its valid password ctrl moves to next page of execution. Orelse it shoud indicate that user/password isnt existing. only existing users can login.
    My frontend is vb6 and backend is oracle.
    I have two txt boxes and 2 cmds. text1 is for username and text2 for password. and commands for login and cancel.

    please help me out people. its urgent..

    Thanks in advance.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Check if the user name and corresponding passsword exists in your database or notusing count. Try to use SQL for the purpose.

    if it is 1 then proceed.

    Comment

    • shreshta
      New Member
      • Sep 2007
      • 15

      #3
      sorry i couldnt get u.. i have the username in that table userdetails. i need to verify whether the user has entered the username which is in userdetails table. thats wat i meant by existign user. userid and password and other detials of user is present in userdetails.

      loginname shoudl be existing username of that table.and each user has a password which is aslo in that table.

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        try this Query.
        [CODE=vb]
        strSql = "Select * from tblUserDetails where fldUserName like '" & txtUserName.Tex t & "' and fldPassword like '" & txtPassword.Tex t & "'"[/CODE]

        Comment

        • shreshta
          New Member
          • Sep 2007
          • 15

          #5
          I tried that qry but control goes to else part. i gave the above string in if part and if it is correct then ctrl goes to next page or if it is not correct then will have to try to login again.. msg invalid user/password is displayed.

          for me when i tried the above qry ctrl goes to else part and says invalid user/password though the user and password exists.

          Comment

          • shreshta
            New Member
            • Sep 2007
            • 15

            #6
            If strsql = "Select * from tblUserDetails where fldUserName like '" & txtUserName.Tex t & "' and fldPassword like '" & txtPassword.Tex t & "'" Then
            LoginSucceeded = True
            MsgBox "login succeded"
            Me.Hide
            Form1.Show

            This is the code i used.

            Comment

            • Ali Rizwan
              Banned
              Contributor
              • Aug 2007
              • 931

              #7
              Originally posted by shreshta
              Hi ..

              I have a table which has user records and some other user details..table name is userdetails.

              My first page when the program runs is login. If the user enters right username..i.e existing username and its valid password ctrl moves to next page of execution. Orelse it shoud indicate that user/password isnt existing. only existing users can login.
              My frontend is vb6 and backend is oracle.
              I have two txt boxes and 2 cmds. text1 is for username and text2 for password. and commands for login and cancel.

              please help me out people. its urgent..

              Thanks in advance.
              If you dont want to save your passsword to a database then save you password and login name to a regidtery value. Its too much secure(i think)
              GOODLUCK
              ALI

              Comment

              • jrtox
                New Member
                • Sep 2007
                • 89

                #8
                Originally posted by shreshta
                If strsql = "Select * from tblUserDetails where fldUserName like '" & txtUserName.Tex t & "' and fldPassword like '" & txtPassword.Tex t & "'" Then
                LoginSucceeded = True
                MsgBox "login succeded"
                Me.Hide
                Form1.Show

                This is the code i used.
                Let see, are you Using ADODC Object OR ADODB?

                1. if your Using ADODC Object then try this one.
                'First Establish ADodc's Connection to your database.

                'Second
                strsql = "Select * from tblUserDetails where fldUserName like '" & txtUserName.Tex t & "' and fldPassword like '" & txtPassword.Tex t & "'"

                Adodc1.CommandT ype = adCmdText
                Adodc1.RecordSo urce = strsql
                Adodc1.refresh

                If Not Adodc1.Recordse t.EOF Then
                LoginSucceeded = True
                MsgBox "login succeded"
                Me.Hide
                Form1.Show
                else
                Msgbox "Invalid UserName/Password"
                End If

                2. IF your Using ADODB


                strsql = "Select * from tblUserDetails where fldUserName like '" & txtUserName.Tex t & "' and fldPassword like '" & txtPassword.Tex t & "'"

                RS.Open strsql,Connecti onString,,,

                If Not RS.EOF Then
                LoginSucceeded = True
                MsgBox "login succeded"
                Me.Hide
                Form1.Show
                else
                Msgbox "Invalid UserName/Password"
                End If

                Regards
                Ervin

                Comment

                • creative1
                  Contributor
                  • Sep 2007
                  • 274

                  #9
                  You can also try this

                  P.S using Adodb

                  Set RS = New ADODB.Recordset
                  RS.Open ("Select * from tblUserDetails Where fldUserName= " & txtUserName.Tex t & " "), Conn, adOpenStatic, adLockOptimisti c, adCmdText

                  If txtpass.Text <> RS.Fields("fldU serName") Then
                  Call MsgBox("Invalid username", vbInformation, "Error!")
                  txtUserName.Tex t = ""
                  txtPassword.Tex t = ""
                  txtUserName.Set Focus
                  Exit Sub
                  elseIf txtPassword.Tex t<> RS.Fields("fldP assword") Then
                  Call MsgBox("Invalid password", vbInformation, "Error!")
                  txtUserName.Tex t= ""
                  txtPassword.Set Focus
                  Exit Sub
                  Else
                  ' you next step

                  end if

                  good luck

                  Farhana

                  Comment

                  • shreshta
                    New Member
                    • Sep 2007
                    • 15

                    #10
                    Thank you friends.. It worked. So i am able to login.. I need one more help. This is also a bit urgent. In fact i need within tonight.

                    The username i use to login should be set to another variable in another module which is declared globally. How to do this. consider that global variable to be g_USERNAME

                    Thanks in advance..Hope to get help from you people within tonight.

                    Comment

                    • creative1
                      Contributor
                      • Sep 2007
                      • 274

                      #11
                      its simple
                      after sucessful login write this line .

                      g_USERNAME=txtU serName.Text
                      regards

                      Comment

                      • jamesd0142
                        Contributor
                        • Sep 2007
                        • 471

                        #12
                        This might not be appropriate.

                        I would use some sort of encryption so when the user enters a password your program encrypts the password then matches it against the encrypted password in the database, then if someone gained access to your database they would still need your program to work out what the password is.

                        Also, this could you a text file because each time a password is added to the file via the program it will be encrypted and any1 lookin at the file sees a load of imformation thats no goo to them.

                        Comment

                        • debasisdas
                          Recognized Expert Expert
                          • Dec 2006
                          • 8119

                          #13
                          Originally posted by hariharanmca
                          try this Query.
                          [CODE=vb]
                          strSql = "Select * from tblUserDetails where fldUserName like '" & txtUserName.Tex t & "' and fldPassword like '" & txtPassword.Tex t & "'"[/CODE]
                          Why to use like in the SQL statment for searching the database table?

                          Comment

                          Working...