VB6.0 Database Password HELP!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gman_00ph
    New Member
    • Jul 2006
    • 9

    #1

    VB6.0 Database Password HELP!!!

    Private Sub Form_Load()
    With Data1
    .DatabaseName = App.Path + "\mydbase.m db"
    .RecordSource = "Select * from usertable"
    .Refresh
    End With
    End Sub
    --------------------------------------------------------------------------------
    "mydbase.md b" is created in Access97

    im using a standard Data Component for "Data1"
    And DBGrid Component for "DBGrid1"

    DBGrid1 Properties is set to:
    DataSource = Data1
    --------------------------------------------------------------------------------
    everything works fine but if i try set a password to my database
    it gives me a

    Run-Time error '3031': Not a valid Password.

    does anybody knows the code to be able to access my database in this point
    or can somebody help me in the code so that i may access my database with a password.

    i must not make any major changes in the codes.

    thanks in advance...
  • Big K Hutch
    New Member
    • Jul 2006
    • 11

    #2
    Try this in the Click area.

    Private Sub txtPassword_Cha nge ()
    If txtUser.Text <> "" Then
    If txtPassword.Tex t <> "" Then
    cmdOK.Enabled = True
    Else: TxtPassword.Set Focus

    End If
    End If
    End Sub

    Comment

    • gman_00ph
      New Member
      • Jul 2006
      • 9

      #3
      Originally posted by Big K Hutch
      Try this in the Click area.

      Private Sub txtPassword_Cha nge ()
      If txtUser.Text <> "" Then
      If txtPassword.Tex t <> "" Then
      cmdOK.Enabled = True
      Else: TxtPassword.Set Focus

      End If
      End If
      End Sub
      it doesnt have to do with textboxes.

      i just the need the way to acces my Database using "Data1" -- Data Component.

      Private Sub Form_Load()
      With Data1
      .DatabaseName = App.Path + "\mydbase.m db"
      ?????.Password= "mypassword"??? ?? <--- something like this or other way
      .RecordSource = "Select * from usertable"
      .Refresh
      End With
      End Sub

      Comment

      • gman_00ph
        New Member
        • Jul 2006
        • 9

        #4
        I open my access97 and set "mypassword " to mydbase.mdb

        and then i re-run, i got this:

        Run-Time error '3031': Not a valid Password.

        help needed please...

        Comment

        • sashi
          Recognized Expert Top Contributor
          • Jun 2006
          • 1749

          #5
          Hi there,

          kindly refer to below code segmet to be able to open password protected ms-access database..

          since you are using DATA control.. you should be able to set the database password under the property window.. highlight the DATA control and press F4 key.. good luck my fren.. :)

          Code:
          Sub OpenDB()
           Dim db As DAO.Database
           Dim ws As DAO.WorkSpace
           Dim rst As DAO.Recordset
           Set ws = DBEngine.WorkSpaces(0)
           Set db = ws.OpenDatabase _
           ("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _
           False, False, "MS Access;PWD=northwind")
           Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
           If rst.RecordCount > 0 Then
             rst.MoveLast
             MsgBox rst!CustomerID
           End If
           rst.Close
           db.Close
          End Sub

          Comment

          • gman_00ph
            New Member
            • Jul 2006
            • 9

            #6
            since you are using DATA control.. you should be able to set the database password under the property window.. highlight the DATA control and press F4 key..
            Just to let you know DATA Component doenst have database password under the property window. So im still hoping for that code...

            Comment

            • Zery
              New Member
              • Jul 2006
              • 1

              #7
              Can someone tell me where to put a constant TRYMAX = 3 so that a user can only input the password 3 times,and after that,the form exits. the coding is:

              rivate Sub Cmdexit_Click()
              End
              End Sub

              Private Sub cmdValid_Click( )

              'This procedure checks the input password
              Dim Response As Integer
              If txtpassword.Tex t = txtpassword.Tag Then
              'If correct, display message box
              MsgBox "You've passed security!", vbOKOnly + vbExclamation, "Access Granted"
              Else
              'If incorrect, give option to try again
              Response = MsgBox("Incorre ct Password", vbRetryCancel + vbCritical, "Access Denied")
              If Response = vbRetry Then
              txtpassword.Sel Start = 0
              txtpassword.Sel Length = Len(txtpassword .Text)
              Else
              End
              End If
              End If
              txtpassword.Set Focus


              End Sub

              Private Sub Form_Activate()
              txtpassword.Set Focus
              End Sub

              Comment

              Working...