syntax error at or near ":"
Posted: Fri 31 Oct 2008 18:39
We are getting the error: syntax error at or near ":"
ErrorCode 42601
FileName "scan.l"
LineNumber 795
Position 76
ProcedureName "base_yyerror"
I am attempting to use the parameterized queries and having some issues. Here is part of the code I'm using. See if anything would appear wrong. We seem to be having problems when the data contains one of the following 2 characters: ` or ". Now if the data contains 2 of these instead of 1, it works fine. I'm looking for a way around this as it's really killing us right now. This only happens in parameterized queries as a similar query without the parameterized part works fine.
using (PgSqlConnection connection = GetNewConnectionAndOpen())
{
PgSqlCommand command = new PgSqlCommand();
command.CommandText = string.Format("Update {0} Set LastName={1},Picture={2} Where PatientID = {3};",
"soapware_charts_generaldemographics",
"'test123\"'",
":Picture",
"'cb35523d-955c-46e0-9eb8-a9c5a6cce2db'");
command.Connection = connection;
PgSqlParameter param = new PgSqlParameter();
param.ParameterName = "Picture";
param.Value = null;
param.DbType = DbType.Binary;
command.Parameters.Add(param);
command.ExecuteNonQuery();
}
If however I use 2 double quote characters it works fine.
using (PgSqlConnection connection = GetNewConnectionAndOpen())
{
PgSqlCommand command = new PgSqlCommand();
command.CommandText = string.Format("Update {0} Set LastName={1},Picture={2} Where PatientID = {3};",
"soapware_charts_generaldemographics",
"'\"test123\"'",
":Picture",
"'cb35523d-955c-46e0-9eb8-a9c5a6cce2db'");
command.Connection = connection;
PgSqlParameter param = new PgSqlParameter();
param.ParameterName = "Picture";
param.Value = null;
param.DbType = DbType.Binary;
command.Parameters.Add(param);
command.ExecuteNonQuery();
}
ErrorCode 42601
FileName "scan.l"
LineNumber 795
Position 76
ProcedureName "base_yyerror"
I am attempting to use the parameterized queries and having some issues. Here is part of the code I'm using. See if anything would appear wrong. We seem to be having problems when the data contains one of the following 2 characters: ` or ". Now if the data contains 2 of these instead of 1, it works fine. I'm looking for a way around this as it's really killing us right now. This only happens in parameterized queries as a similar query without the parameterized part works fine.
using (PgSqlConnection connection = GetNewConnectionAndOpen())
{
PgSqlCommand command = new PgSqlCommand();
command.CommandText = string.Format("Update {0} Set LastName={1},Picture={2} Where PatientID = {3};",
"soapware_charts_generaldemographics",
"'test123\"'",
":Picture",
"'cb35523d-955c-46e0-9eb8-a9c5a6cce2db'");
command.Connection = connection;
PgSqlParameter param = new PgSqlParameter();
param.ParameterName = "Picture";
param.Value = null;
param.DbType = DbType.Binary;
command.Parameters.Add(param);
command.ExecuteNonQuery();
}
If however I use 2 double quote characters it works fine.
using (PgSqlConnection connection = GetNewConnectionAndOpen())
{
PgSqlCommand command = new PgSqlCommand();
command.CommandText = string.Format("Update {0} Set LastName={1},Picture={2} Where PatientID = {3};",
"soapware_charts_generaldemographics",
"'\"test123\"'",
":Picture",
"'cb35523d-955c-46e0-9eb8-a9c5a6cce2db'");
command.Connection = connection;
PgSqlParameter param = new PgSqlParameter();
param.ParameterName = "Picture";
param.Value = null;
param.DbType = DbType.Binary;
command.Parameters.Add(param);
command.ExecuteNonQuery();
}