Hello guys , I have the next problem... I have a query and If the result of the query is greater than zero, the variablee re= "true" . but my code send me error
thnks!
I tried this :
public string Regla_4(string C_E)
{
string query = "SELECT COUNT (Empresas.CODIGO_EMPRESA) FROM Empresas WHERE Empresas.CODIGO_EMPRESA = @codigo";
string R2 = "OK";
string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
SqlCommand command = new SqlCommand(query, con);
command.Parameters.Add("@codigo", SqlDbType.Int).Value = C_E;
con.Open();
command.ExecuteNonQuery();
using (SqlDataReader sdr = command.ExecuteReader())
{
if (sdr.HasRows)
{
while (sdr.Read())
{
if (sdr.GetInt16(0) > 0)
{
R2 = "TRUE";
}
else
{
R2 = "FALSE";
}
}
}
}
return R2;
}