MSARFI 0 Newbie Poster

Dear Sir,

I am facing with login form coding I am first time try to working with oracle database. I am not able to connect through the login form

Here is a screen short for you


And code is here mention

Option Explicit

Dim db As Database

Dim rs As Recordset

Dim rs1 As Recordset

Dim SQL As String

Dim counter As Integer

Dim result As Integer

Dim Server As String

Dim password As String

Private Sub cmdOk_Click()

On Error GoTo errorhandler

  Set rs = db.OpenRecordset(SQL, dbOpenDynaset)

  SQL = "select * from Employee_Master where USR_USERID = """ & UCase(frmSplash.txtLogin.Text) & """"

  If rs.RecordCount = 0 Then

    With txtLogin

        .SelStart = 0

        .SelLength = Len(.Text)

        

    End With

        txtLogin.SetFocus

        MsgBox "Pleas Enter The User ID"

 Else

 SQL = "select * from Employee_Master where USR_USERID = """ & UCase(txtLogin.Text) & """ and user_password = """ & UCase(txtPassword.Text) & """"

  Set rs = db.OpenRecordset(SQL, dbOpenDynaset)

   If rs.RecordCount = 0 Then

    With txtPassword

        .SelStart = 0

        .SelLength = Len(.Text)

    End With

        txtPassword.SetFocus

        MsgBox "Wrong Password Pleas Enter The Password Again"

  Else

     frmMDI.Show

     frmSplash.Hide

     

  End If

 End If

errorhandler:

Select Case Err

        Case 0

          Exit Sub

        Case Else

          MsgBox "Try Again    OK " & ":" & Error, vbExclamation

        Exit Sub

End Select

End Sub

Private Sub cmdExit_Click()

On Error GoTo errorhandler

    Unload Me

    End

errorhandler:

Select Case Err

        Case 0

          Exit Sub

        Case Else

          MsgBox "Wrong Cammad    OK " & ":" & Error, vbExclamation

        Exit Sub

End Select

End Sub

Private Sub TxtLogin_KeyPress(KeyAscii As Integer)

On Error GoTo Useriderrorhandler

If KeyAscii = 13 Then

  SQL = "select * from Employee_Master where USR_USERID = """ & UCase(frmSplash.txtLogin.Text) & """"

  Set rs = db.OpenRecordset(SQL, dbOpenDynaset)

   If rs.RecordCount = 0 Then

    With frmSplash.txtLogin

        .SelStart = 0

        .SelLength = Len(.Text)

    End With

        frmSplash.txtLogin.SetFocus

        MsgBox "Wrong USer ID Pleas Try Again"

  Else

     frmSplash.txtLogin = UCase(frmSplash.txtLogin)

     txtPassword.SetFocus

  End If

 End If

Useriderrorhandler:

Select Case Err

        Case 0

          Exit Sub

        Case Else

          MsgBox "Wrong USer ID Pleas Try Again    OK " & ":" & Error, vbExclamation

        Exit Sub

End Select

End Sub

Private Sub txtpassword_KeyPress(KeyAscii As Integer)

On Error GoTo Userpassworderrorhandler

If KeyAscii = 13 Then

SQL = "select * from Employee_Master where USR_USERID = """ & UCase(frmSplash.txtLogin.Text) & """"

  Set rs = db.OpenRecordset(SQL, dbOpenDynaset)

  If rs.RecordCount = 0 Then

    With frmSplash.txtLogin

        .SelStart = 0

        .SelLength = Len(.Text)

    End With

        frmSplash.txtLogin.SetFocus

        MsgBox "Wrong USer ID Pleas Try Again"

 Else

 SQL = "select * from Employee_Master where USR_USERID = """ & UCase(frmSplash.txtLogin.Text) & """ and USR_PASSWORD = """ & UCase(txtPassword.Text) & """"

  Set rs = db.OpenRecordset(SQL, dbOpenDynaset)

   If rs.RecordCount = 0 Then

    With txtPassword

        .SelStart = 0

        .SelLength = Len(.Text)

    End With

        txtPassword.SetFocus

        MsgBox "Wrong Password Pleas Enter The Password Again"

  Else

     frmMDI.Show

     frmSplash.Hide

     

  End If

 End If

 End If

Userpassworderrorhandler:

Select Case Err

        Case 0

          Exit Sub

        Case Else

          MsgBox "Invailid Password    OK " & ":" & Error, vbExclamation

        Exit Sub

End Select

End Sub

Thanks and Regards

M.S.Arfi

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.