Error associated with delegate

I am trying to use a delegate which should pass a handle of a method (GenerateLinkCollectionFromReader) in a child class to the parent class however when I try to comple I get the error below and I can't figure out why.  Any help would be appreciated!

============== ERROR =================

c:\inetpub\wwwroot\DAL\DataAccessLayer.cs(132):
Inconsistent accessibility: parameter type 'DataAccessLayer.SqlDataAccessLayer.GenerateCollectionFromReader'
is less accessible than method
'DataAccessLayer.SqlDataAccessLayer.ExecuteReaderCmd(System.Data.SqlClient.SqlCommand, DataAccessLayer.SqlDataAccessLayer.GenerateCollectionFromReader)'

============== CODE SNIPS =============

namespace DataAccessLayer
{
      delegate CollectionBase GenerateCollectionFromReader(IDataReader returnData);

      public abstract class SqlDataAccessLayer
      {
            public SqlDataAccessLayer()
            {
            }


(132)-->            protected CollectionBase ExecuteReaderCmd(SqlCommand sqlCmd, GenerateCollectionFromReader gcfr)
            {
                  if (strConnectionString == String.Empty)
                  {
                        throw new ArgumentOutOfRangeException("strConnectionString");
                  }
                  if (sqlCmd == null)
                  {
                        throw new ArgumentNullException("sqlCmd");
                  }

                  SqlConnection cn = new SqlConnection(this.strConnectionString);

                  try
                  {
                        sqlCmd.Connection = cn;
                        cn.Open();
                        CollectionBase temp = gcfr(sqlCmd.ExecuteReader());
                        return temp;
                  }
                  finally
                  {
                        cn.Dispose();
                  }

            } // End ExecuteReaderCmd
}



namespace DataAccessLayer
{

      public class LinkTrackerDataAccessLayer : SqlDataAccessLayer

      public LinkCollection GetLinkByID(int LinkID)
      {
            SqlCommand sqlCmd = new SqlCommand();
            AddParamToSQLCmd(sqlCmd, "@link_id", SqlDbType.Int, 0, ParameterDirection.Input, LinkID);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_LINK_GETLINKBYID);
                              
            GenerateCollectionFromReader sqlData = new GenerateCollectionFromReader(GenerateLinkCollectionFromReader);
           
            LinkCollection stsCollection = (LinkCollection)ExecuteReaderCmd(sqlCmd, sqlData);
            return stsCollection;
      }
      
      private CollectionBase GenerateLinkCollectionFromReader(IDataReader returnData)
      {
            // Create new link collection.
            LinkCollection mlsCollection = new LinkCollection();

            //
            while(returnData.Read())
            {
                  Link newLink = new Link(int.Parse(returnData("link_id")),
                  returnData("title").ToString(),
                  returnData("destinationURL").ToString(),
                  returnData("descript").ToString(),
                  (DateTime)returnData("dateCreated"));
                  mlsCollection.Add(newLink);
            }
            // Return Collction
            return mlsCollection;
      }      // End GenerateLinkCollectionFromReader
           } // End LinkTrackerDataAccessLayer
} // End Namespace
g9supportAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
moduloConnect With a Mentor Commented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 
Justin_WCommented:
Try changing:
   protected CollectionBase ExecuteReaderCmd
to:
   public CollectionBase ExecuteReaderCmd
0
 
g9supportAuthor Commented:
Yeah, I tried that and I still get the "blue squiggly" line with the same error.
hhmmmm....
0
 
g9supportAuthor Commented:
Ok, I figured it out and I'm posting it here just in case someone else has the same problem.

The delegate delcaration was outside of the class scope. I moved the delegate declaration into the class and added  the "protected" modifier to the declaration.

BLAMMO! The problem was solved.

(now, onto more debugging... how fun)
0
 
g9supportAuthor Commented:
I figured out the problem my self and posted it above. How do I close a question if i figured it out myself?
0
All Courses

From novice to tech pro — start learning today.