How do I get ms-access to connect to ms-sql as a different user?

前端 未结 6 1361
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 20:04

How do I get ms-access to connect (through ODBC) to an ms-sql database as a different user than their Active Directory ID?

I don\'t want to specify an account in th

6条回答
  •  遥遥无期
    2021-01-06 20:32

    What I was hoping to do (which I just experimented with) was to refresh the links to the database something like this for each table (Note: I've switched the ODCB connection to SQL Server authentication for this experiment, and added the accounts to the SQL server as well: readonly - which can't to any updates, and readwrite - which has full privileges on the table).

    myTable.Connect = _
                    "ODBC;" & _
                    "DATABASE=" & "MyTestDB" & ";" & _
                    "UID=readonly;" & _
                    "PWD=readonly_password;" & _
                    "DSN=" & "MyTestDB" & ";"
    myTable.RefreshLink
    

    this stops them from editing, but I can't get a later readwrite to work

    myTable.Connect = _
                    "ODBC;" & _
                    "DATABASE=" & "MyTestDB" & ";" & _
                    "UID=readwrite;" & _
                    "PWD=readwrite_password;" & _
                    "DSN=" & "MyTestDB" & ";"
    myTable.RefreshLink
    

    It seems that whichever permission I connect with first, sticks permenantly. If I started readwrite and then go to readonly, the table remains with the readwrite privileges

提交回复
热议问题