• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 19. Using External Data > Working with Passwords

Working with Passwords

In working with passwords, you probably won't want to hard-code the password into your application, because that defeats the purpose of placing a password on your database. In Listing 19.8, the database's password is included in the code, allowing the link to be made to the secured table without any password validation.

Listing 19.8. Embedding a Database Password in Code

Sub LinkToSecured()
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table

    'Instantiate a Catalog object
    Set cat = New ADOX.Catalog

    'Set the ActiveConnection property of the Catalog
    'object to the connection associated with the
    'current project
    cat.ActiveConnection = CurrentProject.Connection

    'Instantiate a Table object
    Set tbl = New ADOX.Table

    'Set the Name property of the Table object
    tbl.Name = "tblLinkedTable"

    'Associate the ParentCatalog of the Table object
    'with the Catalog object
    Set tbl.ParentCatalog = cat

    'Set properties of the Table object
    tbl.Properties("Jet OLEDB:Create Link") = True
    tbl.Properties("Jet OLEDB:Link Provider String") = "ODBC" & _
        ";DATABASE=Pubs" & _
        ";UID=SA" & _
        ";PWD=" & _
        ";DSN=PublisherData"
    tbl.Properties("Jet OLEDB:Remote Table Name") = "Authors"

    'Append the Table object to the Tables collection
    'associated with the Catalog object
    cat.Tables.Append tbl
End Sub


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint