Page 1 of 1

Cleaning Of VarChar PgSqlParameter To Function

Posted: Mon 24 Apr 2006 14:50
by HumanShield
int SearchId = 0;
string Criteria = "you're";

PgSqlCommand cmd = new PgSqlCommand("SELECT public.createsearchresult(@querystring_in);", DBUtils.GetConnection());
cmd.Parameters.Add(new PgSqlParameter("@querystring_in", PgSqlType.VarChar, 100));
cmd.Parameters["@querystring_in"].Value = "%" + Criteria + "%";

cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

results in:

CoreLab.PostgreSql.PgSqlException: syntax error at or near "re"

---

Is this expected behavior? I would have expected this to properly escape single quotes as with other VarChar parameters.

Posted: Tue 25 Apr 2006 07:27
by Alexey
Which version of PostgreSQLDirect .NET do you use?
Your code works fine on the latest one. If you do use the latest version, please provide us with the code of your public.createsearchresult() function as well.

Posted: Wed 26 Apr 2006 16:50
by HumanShield
I'm running the 2.50 professional - pre-release copy. I haven't had the chance to swap over to stable yet :( I'll give that a shot.