Thursday 15 July 2010

sql - Query string from C# using UNION - VarChar to Numeric error -


"strings" = VW_MOS_DPL_AccountValidation WHERE CUST_NUM = '"+ TBAccountNum.Text" from "CIdNNBR" as Voted Voted Cast (LTRIIM (RTIIM (CIDNNBR)) decimal (12, 2)); VW_MOS_DPL_AccountValidation CAST (RTRIM) from "UNION '00.00" (CIDNNBR)) Decimal (12,2) DESC ";

It has worked perfectly before I added a UNION piece, but I no longer need this Because this SQL is a dropdownlist populated and users want this "default" value.

Does anyone help me to understand what I'm doing wrong? I'm getting the exact error:

Error in converting data type varchar to numeric.

CIT_NBR is a VarChar, this is the only column that changes it to a decimal (12,2) Being done because when it is written in a new table If he do not ask is stored by the way, I have no control on the back end ... So, I value will add 00.00 and I do not know how to do it within a SQL string. I tried to use double-quotations, did not like it. I try to use single quotes, this is my top error.

Given and yes, I know about SQL injection risk, but I think that once it will work it actually works. : O)

Try it ...

  string strSQL = Select "DISTINCT CAST (LTRIM (RTRIM (CIT_NBR)) as decimal (12,2)) from VW_MOS_DPL_AccountValidation CIT_NBR where CUST_NUM = '' + TBAccountNum.Text +" select union by order order by order (LTRIM (RTRIM) (CIT_NBR)) AS Decimal (12,2) DESC ";  

No comments:

Post a Comment