[postgis-users] Weird GEOS problem

Emilie Laffray emilie.laffray at gmail.com
Wed Dec 16 08:37:04 PST 2009


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/c13e4957/attachment.html>


More information about the postgis-users mailing list