I am using the below code to display value of the query into the textbox, but I am getting error as
Input string was not in a correct format.
Here is my code:-
private void FillCombo()
{
txtCurrentCompany.Text = CF.ExecuteScaler("SELECT c1.Company_Name FROM dbo.emp_mst em INNER JOIN dbo.company_mst c1 ON em.Comp_mkey = c1.Mkey " + "AND FA_year = '2008' and em.mkey='937'");
}
public string ExecuteScaler(string StrQuery)
{
DB.EConnection();
cmd = new SqlCommand(StrQuery, DB.conn);
cmd.Connection = DB.conn;
int val=Convert.ToInt32(cmd.ExecuteScalar());
DB.conn.Close();
string ret = val.ToString();
return ret;
}
Go to the complete details ...