在文本文件中列出 ODBC DSN 配置
当我的计算机被重新映像或更换时,我必须在 Microsoft ODBC 管理工具中截取每个数据源的屏幕截图,以确保我在新计算机上得到正确的结果。即使去同事的机器,使用他们的设置也可能无法连接到相同的数据源,因为我们可能有不同的配置(至少可以说很烦人)。必须有一种方法将所有这些设置输出到文本文件,而不是截取屏幕截图。搜索我的问题的答案给我带来了很多设置答案,但没有什么只是输出当前设置和配置。如果注册表文件中列出了这些值,我确实找到了一个可能有帮助的值(http://stackoverflow.com/questions/3417142/command-line-to-change-path-to-mdb-file-for-ms- access-odbc-system-dsn)
理想情况下,我想使用批处理文件或 vbscript。我希望看到文本文件显示如下内容:
USER DSN
数据源名称:MS Access 数据库
驱动程序:Microsoft Access 驱动程序
描述:
数据库:X:\Path\to\file.mdb
系统数据库:无
驱动程序页面超时:5
驱动程序缓冲区大小: 2048
驱动程序独占: false
驱动程序只读: false
默认授权用户名:
等等...
系统 DSN
数据源名称: data_warehouse
驱动程序: Adaptive Server IQ 12
说明:
... 包括其他类似的选项卡 ...
数据库服务器名称:data_warehouse
数据库起始行:
依此类推...
When my machine is reimaged or swapped out, I have to take a screenshot of each Data Source in my the Microsoft ODBC Administration tool to make sure I get it right on the new machine. Even going to a coworker's machine, using their settings might not work to connect to the same data sources because we might have different configurations (annoying, to say the least). Rather than taking a screenshot, there must be a way to output all those settings to a text file. Searching for an answer to my question gets me a lot of set-up answers and nothing that just outputs the current settings and configuration. I did find one that might help, if the values are listed in the registry file (http://stackoverflow.com/questions/3417142/command-line-to-change-path-to-mdb-file-for-ms-access-odbc-system-dsn)
Ideally, I'd like to use a batch file or vbscript. I'd like to see the text file say something like:
USER DSN
Data Source Name: MS Access Database
Driver: Microsoft Access Driver
Description:
Database: X:\Path\to\file.mdb
System Database: None
Driver Page Timeout: 5
Driver Buffer Size: 2048
Driver Exclusive: false
Driver Read Only: false
Default Authorization Username:
and so forth...
SYSTEM DSN
Data Source Name: data_warehouse
Driver: Adaptive Server IQ 12
Description:
... including other tabs like this ...
Database Server Name: data_warehouse
Database Start Line:
and so forth...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 odbc 的注册表项导出到文件并将其导入到其他计算机上,例如在我的 Windows 7 64 位计算机上,系统数据源位于 HKEY_LOCAL_MACHINE\Software\ODBC\odbc.ini 中。如果您只需要选择性的文件,您可以轻松编辑导出的文件。
或者,您可以转而使用文件 dsns。使用文件 dsns,您可以将 DSN 的所有设置放入文件中,并使用 FILEDSN=path_to_file 而不是 DSN=dsn_name 进行连接。
You could export the registry entries for odbc to a file and import it on the other machines e.g. on my Windows 7 64 bit machine the system data sources are in HKEY_LOCAL_MACHINE\Software\ODBC\odbc.ini. If you only want selective ones you can easily edit the exported file.
Alternatively, you could move to using file dsns. With file dsns you put all the settings for the DSN in a file and connect using FILEDSN=path_to_file instead of DSN=dsn_name.