[postgis-users] Problem with VB ADODB and Postgis GEOMETRY type

Nicolas RIBOT nri at scot.cnes.fr
Tue Sep 9 10:34:32 PDT 2003

Hi all,

I try to do some updates into a Postgis database using VBA.
I use ADODB.Command object to prepare an SQL statement for the update
command, with binded parameters.

I don't know what kind of DataType I should use when creating my
parameter. I tried the adVarchar, adBinary, adUserDefined without

Here is the pseudo-code: (in this code, the "geometryFromText..."
command is actually dynamically built in the loop)

'...other variables declared upthere
Dim upQuery As String
Dim cmd as ADODB.Command
'update query (prepared statement)
upQuery = "update clcv1 set the_geom=? where gid=?"
Set cmd = New Command
With cmd
    .ActiveConnection = cn
    .CommandType = adCmdText
    .CommandText = upQuery
End With

' binds parameters for the update command
cmd.parameters.Append cmd.CreateParameter("the_geom", adUserDefined,
cmd.parameters.Append cmd.CreateParameter("gid", adInteger,
cmd.Prepared = True
Do While myCondition
        cmd("the_geom").Value = "geometryFromText('POINT (1 2)', -1)"
        cmd("gid").Value = dbID

The code crashes on this line:
cmd("the_geom").Value = "geometryFromText('POINT (1 2)', -1)"
"Run-time error '3421' Application uses a vlaue of the wrong type for
the current operation"

Any hint would be, of course, greatly appreciated.

Nicolas Ribot

  From MAILER-DAEMON  Tue Sep  9 10:36:30 2003
Return-Path: <>
Delivered-To: postgis-users at offsite.refractions.net
Received: from GWOUT.thalesgroup.com (gwout.thalesgroup.com [])
	by offsite.refractions.net (Postfix) with ESMTP id 0074E437A8
	for <postgis-users at postgis.refractions.net>;
	Tue,  9 Sep 2003 10:36:13 -0700 (PDT)
Received: from thalescan.corp.thales ( by GWOUT.thalesgroup.com
	(NPlex 6.5.026)
	id 3F4C863C000BE2CB for postgis-users at postgis.refractions.net;
	Tue, 9 Sep 2003 19:38:38 +0200
Received: from lowplex.mut.thales ([]) by thalescan with InterScan
	Messaging Security Suite; Tue, 09 Sep 2003 19:35:47 +0200
Received: from tisplex.tisfr.thales ( by lowplex.mut.thales (NPlex
	id 3F52DE210006EF80 for postgis-users at postgis.refractions.net;
	Tue, 9 Sep 2003 19:43:28 +0200
Received: from tisplex.tisfr.thales ( by tisplex.tisfr.thales (NPlex
	id 3F5C42BB000128A7 for postgis-users at postgis.refractions.net;
	Tue, 9 Sep 2003 19:35:47 +0200
Received: by sysecaplex.velizy.syseca (NPlex 6.5.026) id 3F52D43000025E07 for
	postgis-users at postgis.refractions.net; Tue, 9 Sep 2003 19:35:47 +0200
From: cedric.bernier at thales-is.com
Subject: Re: [postgis-users] Problem with VB ADODB and Postgis GEOMETRY type 
To: postgis-users at postgis.refractions.net
Date: Tue, 9 Sep 2003 19:35:47 +0200
Message-ID: <3F52D43000025E06 at sysecaplex.velizy.syseca>
In-Reply-To: <200309091735.h89HZNl06537 at cnes.fr>
Precedence: junk
Delivered-To: cedric.bernier at thales-is.com
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable
X-BeenThere: postgis-users at postgis.refractions.net
X-Mailman-Version: 2.1b4
Reply-To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
List-Id: PostGIS Users Discussion <postgis-users.postgis.refractions.net>
List-Post: <mailto:postgis-users at postgis.refractions.net>
List-Subscribe: <http://postgis.refractions.net/mailman/listinfo/postgis-users>,
	<mailto:postgis-users-request at postgis.refractions.net?subject=subscribe>
List-Unsubscribe: <http://postgis.refractions.net/mailman/listinfo/postgis-users>,
	<mailto:postgis-users-request at postgis.refractions.net?subject=unsubscribe>
List-Archive: <http://offsite.refractions.net/pipermail/postgis-users>
List-Help: <mailto:postgis-users-request at postgis.refractions.net?subject=help>
X-List-Received-Date: Tue, 09 Sep 2003 17:36:31 -0000

  -----  The following is an automated response
  -----  to your message generated on behalf of cedric.bernier at thales-is.com

Actuellement en mission à l'étranger, je suis indisponible du 7 Septembre au 8 Octobre 2003 .

More information about the postgis-users mailing list