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 4023144
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:33:45+00:00 2026-05-20T10:33:45+00:00

I am using an array to hold the results of an SQLite query, at

  • 0

I am using an array to hold the results of an SQLite query, at the moment I am using a two dimensional table to do this.

The problem that I have is that I have to manually specify the size of one of the indexes before the array can be used but it feels like a waste as I have no real knowledge of how many rows will be returned. I do use a property which allows me to retrieve the amount of columns that are present which is used in the arrays initialisation.

Example:

using (SQLiteDataReader dr = cmd.ExecuteReader())
{
       results = new object[10,dr.FieldCount];

       while (dr.Read())
       {
            jIterator++;

            for (int i = 0; i < dr.FieldCount; i++)
            {
                    results[jIterator, i] = dr.GetValue(i);
            }
       }
}
//I know there are a few count bugs

Example Storage:

Array contents

I simply add the data to the array for as long as the while loop returns true, in this instance I set the first index to 10 as I already know how many elements are in the database and 10 will be more than enough.

How would I go about changing the array so it’s size can be dynamic, Is this even possible based on the way I am getting the database results?

  • 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-05-20T10:33:46+00:00Added an answer on May 20, 2026 at 10:33 am

    You should not be using an array, you should be using a dynamically-sized container like List<T>. Or, better yet, you could use something like the ADO.NET DataTable, since this is exactly what it’s designed to store, and using a DbDataAdapter will avoid having to repeat the same IDataReader code all over the place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to SQL, and have two tables that hold data(I am using
I have the following array setup, i,e: var myArray = new Array(); Using this
I am using an int array to hold a long list of integers. For
I need to create an array of arrays. I have been using array_map(null,$a,$b,$c) to
I have two arrays, and I am using array_diff_assoc() to get the difference, but
Is there an efficient way to resample a numpy array using zero-order hold? Ideally
I built a symbol table using an array list filled with an object pairs
I would want to create an array that will hold records retrieved from a
I have a site that dynamically creates two arrays of Lat/Long values based on
I have a problem in C. This is the question: Develop a C function

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.