通过VBA将Excel连接到PostgreSQL [英] Connecting Excel to PostgreSQL via VBA

查看:360
本文介绍了通过VBA将Excel连接到PostgreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从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.

请参阅:

  • 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屋!

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