<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Envy Code R VS";
panose-1:2 0 5 9 0 0 0 2 0 4;}
@font-face
{font-family:"Book Antiqua";
panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Book Antiqua","serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EL link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span lang=EN-US style='font-size:9.0pt;font-family:"Book Antiqua","serif";
color:#1F497D'>Yeap, turns out that if I put all parameters as named it works.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:9.0pt;font-family:"Book Antiqua","serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:9.0pt;font-family:"Book Antiqua","serif";
color:#1F497D'>Thanks<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:9.0pt;font-family:"Book Antiqua","serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b>On Behalf Of </b>Emilie
Laffray<br>
<b>Sent:</b> Wednesday, December 16, 2009 6:37 PM<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Subject:</b> Re: [postgis-users] Weird GEOS problem<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p>
<div>
<p class=MsoNormal>2009/12/16 George Vlahakis <<a
href="mailto:g.vlahakis@telenavis.com">g.vlahakis@telenavis.com</a>><o:p></o:p></p>
<div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:10.0pt;color:#0F243E'>Hi Emilie,</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:10.0pt;color:#0F243E'> </span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:10.0pt;color:#0F243E'>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?</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:10.0pt;color:#0F243E'> </span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#400080'>const</span> <span style='color:#400080'>string</span>
<span style='color:#010001'>sql</span> <span style='color:#2E53D1'>=</span> <b><span
style='color:#259241'>"INSERT INTO table ("</span></b></span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#2E53D1'>+</span> <b><span style='color:#259241'>"client,
category, description, geom)"</span></b></span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#2E53D1'>+</span> <b><span style='color:#259241'>"
VALUES (?, ?, ?, GeomFromWKB(?, 4326)) RETURNING id"</span></b>;</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'> </span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#010001'>cmd</span> <span style='color:#2E53D1'>=</span> <span
style='color:#400080'>new</span> <span style='color:#305FB6'>NpgsqlCommand</span>(<span
style='color:#010001'>sql</span>, <span style='color:#010001'>conn</span>);</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#010001'>cmd</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Parameters</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Add</span>(<span style='color:#400080'>string</span><span
style='color:#2E53D1'>.</span><span style='color:#010001'>Empty</span>, <span
style='color:#010001'>request</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>ClientId</span>);</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#010001'>cmd</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Parameters</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Add</span>(<span style='color:#400080'>string</span><span
style='color:#2E53D1'>.</span><span style='color:#010001'>Empty</span>, <span
style='color:#010001'>request</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>CategoryId</span>);</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#010001'>cmd</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Parameters</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Add</span>(<span style='color:#400080'>string</span><span
style='color:#2E53D1'>.</span><span style='color:#010001'>Empty</span>, <span
style='color:#010001'>request</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Description</span>);</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#400080'>byte</span>[] <span style='color:#010001'>bytes</span>
<span style='color:#2E53D1'>=</span> <span style='color:#010001'>GetWkbPolygon</span>(<span
style='color:#010001'>request</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Points</span>);</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#010001'>cmd</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Parameters</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>Add</span>(<span style='color:#400080'>new</span> <span
style='color:#305FB6'>NpgsqlParameter</span>(<span style='color:#400080'>string</span><span
style='color:#2E53D1'>.</span><span style='color:#010001'>Empty</span>, <span
style='color:#010001'>bytes</span>));</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
background:#BFBFBF;-moz-background-clip: border;-moz-background-origin: padding;
-moz-background-inline-policy: continuous;background-attachment:scroll;
background-position-x:0%;background-position-y:0%'><span lang=EN-US
style='font-size:9.0pt;font-family:"Envy Code R VS";background:silver'>
<span style='color:#400080'>int</span> <span style='color:#010001'>id</span> <span
style='color:#2E53D1'>=</span> (<span style='color:#400080'>int</span>)<span
style='color:#010001'>cmd</span><span style='color:#2E53D1'>.</span><span
style='color:#010001'>ExecuteScalar</span>();</span><o:p></o:p></p>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:10.0pt;color:#0F243E'> </span><o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class=MsoNormal>Usually, I use parameters only when I am calling a function.
Here is an example<br>
<br>
agent.AddParameter("@latitude", this.latitude);<br>
agent.AddParameter("@longitude", this.longitude);<br>
<br>
using (NpgsqlDataReader reader =
agent.ExecuteReader("postgisfunction"))<br>
{<br>
if (reader.HasRows)<br>
{<br>
reader.Read();<br>
}<br>
}<br>
}<br>
<br>
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.<br>
<br>
Emilie Laffray<o:p></o:p></p>
</div>
</body>
</html>