I am working in C#.
I have a connection string and I am fetching the details
class CustomerSummaries
{
SqlConnection conn = new SqlConnection();
public IEnumerable<T> GetAll()
{
try
{
SqlCommand cmd = new SqlCommand("GetAll", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlDataReader sdr;
conn.Open();
sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if (sdr.IsDBNull(sdr.GetOrdinal("ContactName")) != true)
{
sdr["ContactName"].ToString();
}
}
}
catch (Exception ex)
{
throw;
//lblErrorMsg.Visible = true;
//lblErrorMsg.Text += "<br><b>getProjectLead_Error: </b> " + ex.Message;
}
finally
{
conn.Close();
}
}
}
I am getting an error that says Not all code path return a value, how could fix my code?