SQL 查找我的数据库的 DSN?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2899529/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Finding The DSN To My Database?
提问by sooprise
I have an SQL database and want to connect to it using VBA in order to support some legacy functionality. I'm using an ADODB connection and need to know what my database DSN is. How can I find this?
我有一个 SQL 数据库,并希望使用 VBA 连接到它以支持某些旧功能。我正在使用 ADODB 连接并且需要知道我的数据库 DSN 是什么。我怎样才能找到这个?
I'm using SQL Server 2008, thanks! :D
我正在使用 SQL Server 2008,谢谢!:D
回答by egrunin
A DSN (data source name) is an indirect way of referring to the database. You have to create them manually (or semi-automatically using a wizard of some kind). Go to ControlPanel->AdministrativeTools->DataSources (ODBC)
to see if one has already been defined for the database to which you want to connect.
DSN(数据源名称)是引用数据库的间接方式。您必须手动创建它们(或使用某种向导半自动创建)。转到ControlPanel->AdministrativeTools->DataSources (ODBC)
查看是否已经为要连接的数据库定义了一个。
But I think you might mean "connection string", not "DSN". There are many, many ways to tell ADODB how to find and connect to your database (DSNs
are just one of those), but you alwaysneed a connection string.
但我认为您的意思可能是“连接字符串”,而不是“DSN”。有很多方法可以告诉 ADODB 如何查找和连接到您的数据库(DSNs
只是其中之一),但您始终需要一个连接字符串。
I have often turned to ConnectionStrings.comto help me through the maze of similar-but-not-identical options.
我经常求助于ConnectionStrings.com来帮助我解决类似但不相同的选项的迷宫。
回答by John Saunders
There may not bea DSN. DSNs are not created automatically.
可能没有成为一个DSN。DSN 不会自动创建。
I'm not sure you really mean DSN, as a DSN is an ODBC concept. Still, look in Administrative Tools->Data Sources (ODBC).
我不确定你的意思是 DSN,因为 DSN 是一个 ODBC 概念。不过,请查看管理工具-> 数据源 (ODBC)。