I am trying to get the String value in a list but getting error as
Input string was not in a correct format.
There are many helpful links available on the net but didn't resolved mine one.
Here is my code.
newRow["EXP_TYPE_ID"] = Convert.ToString(e.Record["EXP_TYPE"]);
newRow["EXP_TYPE"] = CF.ExecuteScaler("Select Type_desc from type_mst where Type_Code = 'PAR' and Type_Abbr ='" + Convert.ToString(e.Record["EXP_TYPE"]) + "'").ToString();
and CF.ExecuteScaler
public string ExecuteScaler(string StrQuery)
{
DB.EConnection();
cmd = new OracleCommand(StrQuery, DB.conn);
cmd.Connection = DB.conn;
int val=Convert.ToInt32(cmd.ExecuteScalar());
DB.conn.Close();
string ret = val.ToString();
return ret;
}
Note I can't change Scaler function.
update
StrQuery = Select Type_desc from type_mst where Type_Code = 'PAR' and Type_Abbr ='PUR'
and the value of the query
PURCHASER
StrQuerywhen you pass it toExecuteScaler()?Type_descfrom the query? if it's string, what are the possible values? it looks like it's not convertible tointand that's why it's throwing the exception