PRB: Can't Connect Data Control to a Password Protected MDB

ID: Q160169


The information in this article applies to:
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0


SYMPTOMS

If you attempt to use the Data control to connect to a password-protected Access database at design time, you will receive the error message:

"Not a valid password"

Specifically, this error will occur when setting the RecordSource property of the Data control.


RESOLUTION

In the Properties window, set the following properties for the Data control:


      Property             Value of Property
      ----------------   ---------------------
      DatabaseName         ATEST.MDB
      Connect              ;pwd=aaa
      RecordSource         Table1 

NOTE: You must set the DatabaseName property first, then set the connect property. If the properties are not set in this order, you will receive the same error message.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.


  2. In the Load event for Form1, place the following code:
    
       Private Sub Form_Load()
    
         Dim DB As Database
         Dim tblDef As TableDef, fld As Field
    
         Set DB = DBEngine.Workspaces(0).CreateDatabase("C:\ATEST.MDB", _
             dbLangGeneral, dbEncrypt)
         DB.NewPassword "", "aaa"
         ' Create new TableDef.
         Set tblDef = DB.CreateTableDef("Table1")
         ' Add field to tblDef.
         Set fld = tblDef.CreateField("Field1", dbInteger)
         tblDef.Fields.Append fld
         ' Save TableDef definition by appending it to TableDefs collection.
         DB.TableDefs.Append tblDef
         DB.Close
         MsgBox "ATEST.MDB and Table1 is created."
    
       End Sub
     


  3. Run the program by pressing the F5 key. A password-protected database called ATEST.MDB will be created.


  4. Start another instance of Visual Basic 4.0. Form1 is again created by default.


  5. Add a Data control to Form1.


  6. In the Properties window, set the DatabaseName property of the Data control to "C:\ATEST.MDB." If you try to set the RecordSource property, you will receive the error message described above.


Additional query words: kbVBp400 kbVBp600 kbdse kbDSupport kbVBp Kbstream kbdao

Keywords : kbGrpVBDB
Version :
Platform : NT WINDOWS
Issue type :


Last Reviewed: January 5, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.