public DataSet GetFunc()
{
int iRet = 0;
DataSet ds = new DataSet();
SqlConnection sqlConnection = new SqlConnection();
try
{
iRet = connect(ref sqlConnection);
if (DB_SUCCESS_CONNECT == iRet)
{
SqlCommand sqlCommand = new SqlCommand("", sqlConnection);
String strQuery = "Select ID, Did, FirstName from Users";
sqlCommand.CommandText = strQuery;
SqlDataAdapter adaptor = new SqlDataAdapter(sqlCommand);
adaptor.Fill(ds);
sqlConnection.Close();
return ds;
}
}
catch (Exception e)
{
disconnect(ref sqlConnection);
}
return null;
}
Not all paths of your code return value, but have to. If DB_SUCCESS_CONNECT!=iRet
you won't return result. Try returning some default value, maybe null like above. Another problem is that you are not returning value if exception is thrown. When exception is thrown you are disconnecting and not returning any value.