Embedding a Database Password in Code : Database Password « Access « VBA / Excel / Access / Word






Embedding a Database Password in Code

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

    Set cat = New ADOX.Catalog

    cat.ActiveConnection = CurrentProject.Connection

    Set tbl = New ADOX.Table
    tbl.Name = "tblLinkedTable"
    Set tbl.ParentCatalog = cat

    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") = "Employees"
    cat.Tables.Append tbl
End Sub

 








Related examples in the same category

1.Setting a Database Password
2.Setting a Database Password with SQL command
3.Deleting a Database Password with SQL command
4.Changing a User Password
5.Requiring Password Validation