Subscribe to this thread
Home - General / All posts - accessing Postgres from Manifold 8 with an external script
artlembo


3,417 post(s)
#19-Feb-24 18:00

I have a script running in Manifold that connects to Postgres:

Sub Main

 Set DataConnect = document.NewDataSource

 DataConnect.ConnectionType = "PostGRESQL"

 DataConnect.ConnectionString = "host=127.0.0.1 port=5432 user=postgres password=postgres dbname=phl"

 DataConnect.LinkDrawingFromTableGeometry "public.broadbandtable""geom", ColumnTypeGeomWKB

End Sub

I have rewritten the script for outside of Manifold as:

set mfd = createobject("Manifold.Application")

 Set document = mfd.NewDocument("c:\projects\\manifold8.map",false)

 Set theCompS = document.ComponentSet

'

'  Database connection string

'

 Set DataConnect = document.NewDataSource

 DataConnect.ConnectionType = "PostGRESQL"

 DataConnect.ConnectionString = "host=localhost user=postgres password=postgres dbname=phl"

 DataConnect.LinkDrawingFromTableGeometry "public.broadbandtable""geom", ColumnTypeGeomWKB

 msgbox("hello")

everything works fine inside of Manifold. But, when I run the script from outside of Manifold 8, I get the error:

Error: invalide argument

Code: 80020009

Source: Manifold System

I've written some lines in my script to print out the names of existing components, just to make sure they exist and that my script is actually inside the .map. Also, I have copied the postgres .dlls into my Windows\System32 folder, and unblocked them.

So, I don't know what the reason for the error is. The line:

 DataConnect.LinkDrawingFromTableGeometry "public.broadbandtable""geom", ColumnTypeGeomWKB

so I'm not sure why it works inside Manifold but not outside.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.