问题描述
我有一个使用链接的 sql server 表作为数据源的访问表单.我需要尽快将这个文件分发给其他用户,我需要一种方法来以编程方式将 DSN 安装到他们的机器上.这是手动设置链接的过程:
I have an Access Form that uses a linked sql server table as a datasource. I will need to distribute this file to other users soon and I need a way to programmaticly install the DSN to their machines. This is the process of manually setting up the link:
外部数据 > 更多 > ODBC 数据库 > 数据源链接 > 机器数据源选项卡 >按新建 > 用户数据源 > sql server > name=up to you;server= serverName > SQL server 如何验证登录ID的真实性?使用网络登录ID进行Windows NT身份验证 >附加数据库文件名(数据库名称)>选择表并按确定
External Data > More > ODBC Database > Link to data source > Machine data source tab > press new > user data source > sql server > name=up to you; server= serverName > How should SQL server verify the autheticity of the login ID? With windows NT authentication using the network login ID > Attach database File Name (database name) > choose the table and press ok
这就是我访问我的表时所做的,但我希望用户可以按下按钮并访问该表,同时使用 Windows NT 身份验证进行身份验证.
That is what I did to access my table but I would like it so that the user can press a button and get access to the table and at the same time be authenticated by using windows NT authentication.
我很难找到一种在 access vba 代码中编写此代码的方法,有人可以指导我朝正确的方向发展吗?
I am having trouble finding a way to write this in access vba code can someone direct me in the right direction?
推荐答案
作为一般规则,您会发现使用无 DSN 的连接会取得更大的成功.这将消除许多问题和问题.此处概述了如何使用无 DSN 连接:
As a general rule you find MUCH better success by using a DSN less connection. This will eliminate many issues and problems. How to use a DSN less connection is outlined here:
http://www.accessmvp.com/DJSteele/DSNLessLinks.html
而且您也不想在连接字符串中存储用户名 + 密码,而只想登录"一次.这再次节省了大量麻烦,也意味着您的连接字符串和/或 DSN 不必在实际链接中保存和公开用户名和密码.
And also you do NOT want to store the user name + password in the connection string, but only "log on" one time. Again this saves huge hassles and also means your connection strings and/or DSN does not have to save and expose the user name and password in the actual links.
这种方法意味着您可以有不同的登录,而不必重新链接或更改现有的表链接.
And this approach means you can have different logons and NOT have to re-link or change existing table links.
以下显示了如何使用缓存登录,从而允许用户进行不同的登录,而无需重新链接您的表.
The follow shows how to use a cached logon and this thus allows one to have different logons without having to re-link your tables.
https://blogs.office.com/en-us/2011/04/08/power-tip-improve-the-security-of-database-connections/
我强烈建议您在使用链接表到 SQL Server 时采用上述两种方法.
I highly recommend you adopt both of the above approaches when using linked tables to SQL server.
这篇关于如何以编程方式创建 DSN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!