I am porting a ASP.NET Webforms application from MSSQL to PostgreSql. I am running into a problem with this code snippet.
string checkIfExist ="SELECT COUNT(*) FROM tblHairRecord WHERE customerid = @customerID AND typetitle1= @titleParam AND type1_1=@typeValue";
//Open the SQL Connectionn
con.Open();
//Set all the parameters
NpgsqlCommand cmdChk = new NpgsqlCommand(checkIfExist,con);
cmdChk.Parameters.Add("@customerID", NpgsqlDbType.Integer);
cmdChk.Parameters.Add("@titleParam", NpgsqlDbType.Char, 10);
cmdChk.Parameters.Add("@typeValue", NpgsqlDbType.Char, 10);
cmdChk.Parameters["@customerID"].Value = lblCustIDed.Text;
cmdChk.Parameters["@titleParam"].Value = "顔型";
cmdChk.Parameters["@typeValue"].Value = "卵型";
//Run the the count query and Close the connection
int checkIfExistCount = (int)cmdChk.ExecuteScalar();
con.Close();
The Error that the web page is returning is *
Input string was not in a correct format.
* The stack trace leads me to the line in the snippet
int checkIfExistCount = (int)cmdChk.ExecuteScalar();
I know that this snippet works because it executes with no problems in the MSSQL environment. I am fairly new to PostgreSql, and think basically PostgreSql is not liking the "int" there for it assumes the wrong format is being submitted.
@titleParamand the@typeValuevalues with plain ASCII characters?[tblHairRecord]reminds me SQL-Server, not postgres