tag:blogger.com,1999:blog-40365503257194045752024-02-20T09:08:36.859-08:00What I need to knowGeorge DeWolfhttp://www.blogger.com/profile/04838690888556131844noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-4036550325719404575.post-84514230268733863652011-11-28T13:49:00.000-08:002011-11-28T13:51:29.254-08:00Connecting to postgres from Excel (visual basic)I am trying to insert & update records from Excel (visual basic) into a postgres table but am having problems connecting to postgres.<br />
I am able to build querries in Excel no problem.<br />
<br />
The postgres documentation give the following example to connect...<br />
<br />
'Open the connection<br />
cn.Open "DSN=<MyDataSourceName>;" & _<br />
"UID=<MyUsername>;" & _<br />
"PWD=<MyPassword>;" & _<br />
"Database=<MyDatabaseName>"<br />
<br />
<br />
I assume that the UID, PWD and Database are the same as the ones I would use in setting up the data source queries. the DSN is where I seem to fall down..<br />
<br />
when I set up the datasource queries I specify "localhost" as the Server and 5432 as the Port<br />
so I have tried using localhost:5432 as the DSN; so my code looks like:<br />
<br />
Sub UpdateRecord()<br />
Dim cnn As ADODB.Connection<br />
Dim rst As ADODB.Recordset<br />
<br />
<br />
'Open the connection<br />
cnn.Open "DSN=localhost:5432;" & _<br />
"UID=postgres;" & _<br />
"<a href="mailto:PWD=!Q@aw3se4">PWD=password</a>;" & _<br />
"Database=postgres"<br />
End Sub<br />
<br />
as the DSN but get <br />
"Run Time Error 91"<br />
"Object variable or With block variable not set<br />
<br />
<br />
any ideas on what I am doing wrong??George DeWolfhttp://www.blogger.com/profile/04838690888556131844noreply@blogger.com5