通过VBA将Excel连接到PostgreSQL [英] Connecting Excel to PostgreSQL via VBA
问题描述
是否可以从Excel中的VBA进行类似SELECT
的查询,所以我可以从Excel中查询PostgreSQL数据库?
Is it possible to make query like SELECT
from VBA in Excel, so I can query a PostgreSQL DB from Excel?
如果可能,请向我解释如何连接数据库.我在Google上搜索,但没有找到结果.
If is possible please explain me how to connect to the database. I was looking in Google but found no results.
推荐答案
在PostgreSQL中创建描述所需数据的表或视图.
Create a table or view in PostgreSQL that describes the data you want.
使用VBA中的ODBC或ADO连接来连接到PostgreSQL.如果使用ODBC,则需要通过odbcad32.exe
创建一个DSN,然后在VB中使用DSN,直接连接并不容易.
Use an ODBC or ADO connection from VBA to connect to PostgreSQL. If using ODBC you'll need to create a DSN via odbcad32.exe
then use the DSN in VB, it isn't easy to just connect directly.
请参阅:
- 在VBA中使用ADO连接到PostgreSQL
- PostgreSQL查询到Excel工作表
- http://jackdebear.blogspot .com.au/2011/11/connecting-to-postgres-from-excel.html
- 启用导入/导出流程远程Postgres数据库和excel工作簿之间
- ADO是否可以与ODBC驱动程序一起使用或只有OLE DB提供程序?
- 如何放置使用Excel VBA和ADO将结果查询到数据表中?
- Using ADO in VBA to connect to PostgreSQL
- PostgreSQL Query to Excel Sheet
- http://jackdebear.blogspot.com.au/2011/11/connecting-to-postgres-from-excel.html
- Enabling import/export flows between a remote postgres database and excel workbooks
- Does ADO work with ODBC drivers or only OLE DB providers?
- How to put query results into a datatable with Excel VBA and ADO?
使用Oracle的书面示例更好,但原理相同-ODBC/ADO.
Better written eample that uses Oracle, but the principles are the same - ODBC/ADO.
这篇关于通过VBA将Excel连接到PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!