[postgis-users] Weird GEOS problem

George Vlahakis g.vlahakis at telenavis.com
Wed Dec 16 12:10:01 PST 2009


Yeap, turns out that if I put all parameters as named it works.

 

Thanks

 

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Emilie Laffray
Sent: Wednesday, December 16, 2009 6:37 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Weird GEOS problem

 

 

2009/12/16 George Vlahakis <g.vlahakis at telenavis.com>

Hi Emilie,

 

Im trying to port over to npgsql but I cannot get the GeomFromWKB
function to get called correctly. No matter what I do with the wkb
parameter the query failes (error near \",\"). Any hints?

 

                const string sql = "INSERT INTO table ("

                                   + "client, category, description,
geom)"

                                   + " VALUES (?, ?, ?, GeomFromWKB(?,
4326)) RETURNING id";

 

                cmd = new NpgsqlCommand(sql, conn);

                cmd.Parameters.Add(string.Empty, request.ClientId);

                cmd.Parameters.Add(string.Empty, request.CategoryId);

                cmd.Parameters.Add(string.Empty, request.Description);

                byte[] bytes = GetWkbPolygon(request.Points);

                cmd.Parameters.Add(new NpgsqlParameter(string.Empty,
bytes));

                int id = (int)cmd.ExecuteScalar();

 

Usually, I use parameters only when I am calling a function. Here is an
example

agent.AddParameter("@latitude", this.latitude);
agent.AddParameter("@longitude", this.longitude);

  using (NpgsqlDataReader reader =
agent.ExecuteReader("postgisfunction"))
  {
    if (reader.HasRows)
    {
     reader.Read();
    }
  }
}

In this case, @latitude and @longitude are the name of the parameters
for my function in Postgresql. I never write SQL statement directly in
code. I hope this will be useful to you.

Emilie Laffray

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20091216/e7f427f7/attachment.html>


More information about the postgis-users mailing list