Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Feb 2002
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing password to Open method in sub (A2K)

    Microsoft provided the following code to list who is in a database. I am trying to learn how I can provide a password to the Open method in the code. The password was created with the Tools, Security menu.

    I currently use LDBView, but wanted to explore this.

    Thanks,

    Randy

    ================================================== ===================
    Sub ShowUserRosterMultipleUsers()
    Dim cn As New ADODB.Connection
    Dim cn2 As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim i, j As Long

    cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    cn.Open "Data Source=c:Northwind.mdb"

    cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=c:Northwind.mdb"

    ' The user roster is exposed as a provider-specific schema rowset
    ' in the Jet 4 OLE DB provider. You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
    , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

    'Output the list of all users in the current database.

    Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
    "", rs.Fields(2).Name, rs.Fields(3).Name

    While Not rs.EOF
    Debug.Print rs.Fields(0), rs.Fields(1), _
    rs.Fields(2), rs.Fields(3)
    rs.MoveNext
    Wend

    End Sub
    ================================================== ===================

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing password to Open method in sub (A2K)

    According the helpfile in the section NewPassword Method :<blockquote><hr>If object refers to a User object that is not yet appended to a Users collection, an error occurs. To set a new password, you must either log on as the user whose account you're changing, or you must be a member of the Admins group. [b]The Password property of a User object is write-only
    Francois

  3. #3
    Star Lounger
    Join Date
    Feb 2002
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing password to Open method in sub (A2K)

    Thanks Francois, but I'm actually not trying to determine the password. I already know it - I'm trying to use the Sub provided on a database that has a password that I created. I want to know if the Open method can be provided a known password so it will not result in a run time error.

    Randy

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing password to Open method in sub (A2K)

    Did this help :
    Dim cn As New Connection
    cn.Connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databaseName;User ID=userName;Password=userPassword;"
    cn.open
    ...
    Francois

Posting Permissions

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