public bool ConnectToDB()
{
SqlConnection sqlConnect = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
try
{
sqlConnect.Open();
if (sqlConnect.State == ConnectionState.Open)
{
return true;
}
}
catch (SqlException ex)
{
// some code here...
}
finally
{
sqlConnect.Close();
}
}
when I run this code,it is giving an error
Error 'DataAccess.ConnectToDB()': not all code paths return a value