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:

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?
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.NETDataTable, since this is exactly what it’s designed to store, and using aDbDataAdapterwill avoid having to repeat the sameIDataReadercode all over the place.