Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    1

    Question Unanswered: sql server-login with vba

    Hi,

    Im working on an access2000-database, which uses tables from a sql-
    server via an odbc-data source (dsn). So far so good...

    When you start the database and use one of the tables for the first time,
    appears the sql server-login, where you have to enter username and
    password. After that you dont need to enter it again until closing the
    database.

    What Im looking for is a possibility, to avoid the login-window (on
    the SQL server I have no influence) and to perform the login with vba.

    The reason is, that I dont want every user to know username and
    password for the sql server. But even with this solution, the sql server
    login should be performed only once.

    I really hope that someone can help me!

    Roland

  2. #2
    Join Date
    Sep 2003
    Location
    Texas
    Posts
    13
    I'm looking for an easy way to do this too. Relink the tables on startup, thats the only way I know how to do it. There has to be a better way though.

    Chad

  3. #3
    Join Date
    Sep 2003
    Location
    Texas
    Posts
    13
    This worked for me...

    Dim db as Database
    Dim tbl as TableDef

    set db=currentdb

    set tbl=db.tabledefs("table name")

    tbl.connect="ODBC;driver={SQL Server};Server=servername;Database=databasename;UI D=loginname;pwd=password"

    tbl.refreshlink


    You only have to do this for one table and the database will remember the login for the rest. But all the tables have to be linked to the same source in order for it to work on multiple tables.

    Also keep in mind that you are storing the login and password in a spot that isn't secure, so maybe it can be stored in an encrpyted table or something like that.

    Chad

Posting Permissions

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