Yeap, turns out that if I put all parameters as named it works.
Thanks From: [email protected] [mailto:[email protected]] 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 <[email protected]> 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
_______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
