Cleaning Of VarChar PgSqlParameter To Function

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
HumanShield
Posts: 7
Joined: Mon 24 Apr 2006 14:30

Cleaning Of VarChar PgSqlParameter To Function

Post by HumanShield » Mon 24 Apr 2006 14:50

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.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 25 Apr 2006 07:27

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.

HumanShield
Posts: 7
Joined: Mon 24 Apr 2006 14:30

Post by HumanShield » Wed 26 Apr 2006 16:50

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.

Post Reply