如何以编程方式创建DSN? [英] How can I programmatically create a DSN?

查看:106
本文介绍了如何以编程方式创建DSN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问表,该表使用链接的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数据库>链接到数据源>机器数据源选项卡> 按new>用户数据源> sql server> name =由您决定; server = serverName> SQL Server应该如何验证登录ID的真实性?使用Windows NT身份验证并使用网络登录ID >附加数据库文件名(数据库名称)>选择表,然后按确定

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.

我强烈建议您在使用链接表到SQL Server时采用以上两种方法.

I highly recommend you adopt both of the above approaches when using linked tables to SQL server.

这篇关于如何以编程方式创建DSN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆