如何设置 ODBC .DSN 文件以允许其访问 Postgresql 中的任何数据库?
我正在编写一个 MFC 应用程序来自动使用 ODBC 配置 Postgresql 供另一个应用程序使用。 这个想法是,用户运行应用程序,它会自动创建数据库和其中的表。 我的问题是,当我设置文件 DSN 时,它似乎需要它将访问的数据库的名称。 这在 DSN 文件中显示为 ..
DATABASE=mydb
但是我还没有创建 mydb 所以无法连接到 Postgresql ! 我尝试编辑 DSN 文件,因此该行显示为 ..
DATABASE=
并将其完全删除,但随后出现错误并且无法连接。
DSN 文件是否可以允许访问任何数据库? 如果是这样我该怎么做?
谢谢伊恩
I'm writing an MFC App to automatically configure Postgresql with ODBC for use by another app. The idea being that the user runs the app and it automatically creates the database and the tables within it. My problem is that when I set up the File DSN it seems to require the name of the database it will access. This appears in the DSN file as ..
DATABASE=mydb
However I haven't created mydb yet so can't connect to Postgresql ! I have tried editing the DSN file so this line reads ..
DATABASE=
and removing it totally but then I get an error and can't connect.
Is it possible for a DSN file to allow access to any database ? If so how do I do this ?
Thanks
Ian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不熟悉 PostgreSql,但是 SQL Server 中是否有像“master”这样的数据库,您可以首先连接到该数据库,然后再使用其他数据库?
您可能还想尝试 connectionstrings.com
I am not familiar with PostgreSql, but is there a database like 'master' in SQL Server that you could initially connect to, and then later use a different database?
You might also want to try connectionstrings.com
PostgreSQL 的数据库“postgres”始终存在,并且可用于执行此类任务。
The database 'postgres' always exists for PostgreSQL and can be used for tasks like these.