Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8036293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:34:18+00:00 2026-06-05T02:34:18+00:00

I’m trying to populate a generic collection but having problems. I’m trying to populate

  • 0

I’m trying to populate a generic collection but having problems. I’m trying to populate myBookings, which is supposed to store a List. The methods below should fill myBookings with the correct List but for some reason when I count the result (int c), I’m getting a return of 0. Can anyone see what I’m doing wrong?

// .cs

public partial class _Default : System.Web.UI.Page
{    
    iClean.Bookings myBookings = new iClean.Bookings();
    iClean.Booking myBooking = new iClean.Booking();
    iClean.Controller myController = new iClean.Controller();

    ListItem li = new ListItem();

    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentFname.Text = Profile.FirstName;
        CurrentUname.Text = Profile.UserName;
        CurrentLname.Text = Profile.LastName;

        myBookings.AllBookings = this.GetBookings();

        int c = myBookings.AllBookings.Count();

        Name.Text = c.ToString();
        Address.Text = myBooking.Address;
        Phone.Text = myBooking.Phone;
        Date.Text = myBooking.DueDate.ToString();
        Comments.Text = myBooking.Comments;        
    }

    public List<iClean.Booking> GetBookings()
    {
        List<iClean.Booking> bookings = new List<iClean.Booking>();
        ArrayList records = this.Select("Bookings", "");
        for (int i = 0; i < records.Count; i++)
        {
            iClean.Booking tempBooking = new iClean.Booking();
            Hashtable row = (Hashtable)records[i];
            tempBooking.ID = Convert.ToInt32(row["ID"]);
            tempBooking.Name = Convert.ToString(row["ClientName"]);
            tempBooking.Address = Convert.ToString(row["ClientAddress"]);
            tempBooking.Phone = Convert.ToString(row["ClientPhone"]);

            tempBooking.DueDate = Convert.ToDateTime(row["Bookingdate"]);
            tempBooking.Completed = Convert.ToBoolean(row["Completed"]);
            tempBooking.Paid = Convert.ToBoolean(row["Paid"]);
            tempBooking.Cancelled = Convert.ToBoolean(row["Cancelled"]);
            tempBooking.ReasonCancelled = Convert.ToString(row["ReasonCancelled"]);
            tempBooking.ContractorPaid = Convert.ToBoolean(row["ContractorPaid"]);
            tempBooking.Comments = Convert.ToString(row["Comments"]);

            tempBooking.Windows = Convert.ToBoolean(row["Windows"]);
            tempBooking.Gardening = Convert.ToBoolean(row["Gardening"]);
            tempBooking.IndoorCleaning = Convert.ToBoolean(row["IndoorCleaning"]);

            bookings.Add(tempBooking);
        }

        return bookings;
    }

    public ArrayList Select(string table, string conditions)
    {
        // Create something to hosue the records.
        ArrayList records = new ArrayList();

        try
        {
            // Open a connection.
            OleDbConnection myConnection = new OleDbConnection(this.getConnectionString());
            myConnection.Open();

            // Generate the SQL
            string sql = "SELECT * FROM " + table;
            if (conditions != "") { sql += " WHERE " + conditions; }

            // Console.WriteLine("Select SQL: " + sql); // In case we need to debug

            // Run the SQL
            OleDbCommand myCommand = new OleDbCommand(sql, myConnection);
            OleDbDataReader myReader = myCommand.ExecuteReader();

            // Go through the rows that were returned ...
            while (myReader.Read())
            {
                // ... create Hashtable to keep the columns in, ...
                Hashtable row = new Hashtable();

                // ... add the fields ...
                for (int i = 0; i < myReader.FieldCount; i++)
                {
                    row.Add(myReader.GetName(i), myReader[i]);
                }

                // ... and store the row.
                records.Add(row);
            }

            // Make sure to close the connection
            myConnection.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }

        return records;
    }

    public string getConnectionString()
    {
        string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=IQQuotes.accdb;";

        return connectionString;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:34:19+00:00Added an answer on June 5, 2026 at 2:34 am

    Just a guess, but try this:

    public List<iClean.Booking> GetBookings()
    {
        List<iClean.Booking> bookings = new List<iClean.Booking>();
        ArrayList records = this.Select("Bookings", "");
        iClean.Booking tempBooking = new iClean.Booking();
        for (int i = 0; i < records.Count; i++)
        {
            tempBooking = new iClean.Booking();
            Hashtable row = (Hashtable)records[i];
            tempBooking.ID = Convert.ToInt32(row["ID"]);
            tempBooking.Name = Convert.ToString(row["ClientName"]);
            tempBooking.Address = Convert.ToString(row["ClientAddress"]);
            tempBooking.Phone = Convert.ToString(row["ClientPhone"]);
    
            tempBooking.DueDate = Convert.ToDateTime(row["Bookingdate"]);
            tempBooking.Completed = Convert.ToBoolean(row["Completed"]);
            tempBooking.Paid = Convert.ToBoolean(row["Paid"]);
            tempBooking.Cancelled = Convert.ToBoolean(row["Cancelled"]);
            tempBooking.ReasonCancelled = Convert.ToString(row["ReasonCancelled"]);
            tempBooking.ContractorPaid = Convert.ToBoolean(row["ContractorPaid"]);
            tempBooking.Comments = Convert.ToString(row["Comments"]);
    
            tempBooking.Windows = Convert.ToBoolean(row["Windows"]);
            tempBooking.Gardening = Convert.ToBoolean(row["Gardening"]);
            tempBooking.IndoorCleaning = Convert.ToBoolean(row["IndoorCleaning"]);
    
            bookings.Add(tempBooking);
        }
    
        return bookings;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.