Hi everyone I have a problem with the input string, I think I know the cause of this problem but I can't resolve it.
I have a database ,I'm using a request that return null
,because the table is empty. The null
I return it as a double. So i want to make a condition that verify if it is null or not.
This is my method:
public static double CREDIT()
{
double Total;
try
{
CLSERVICES.CON.Open();
string req = "select SUM(F.Reste)from RELATION as R , Facture as F where R.NRelation = F.Relation";
SqlCommand cmd = new SqlCommand(req, CLSERVICES.CON);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
Total= double.Parse(dr.GetValue(0).ToString());
}
else
{
Total= 0;
}
dr.Close();
CLSERVICES.CON.Close();
return Total;
}
catch (SqlException E)
{
MessageBox.Show(E.Message, "<!!!>", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 0;
}
}