B
Brent
I'm having a hard time wrapping my head around how to build a
multi-dimensional array of n length out of a DataReader loop. Take this
pseudo-code:
=======================================
public string[,] get_array(string sql)
{
//create db connection & open
string[,] arrReturn = new String[,];
SqlDataReader dataReader = myCommand.ExecuteReader();
if (dataReader.HasRows)
{
while (dataReader.Read())
{
//next line I don't know what to do!
arrReturn.AddToArray = {dataReader[0].ToString(),
dataReader[1].ToString()};
}
}
myConn.Close();
return arrReturn;
}
========================================
I can't seem to find anything in my Google searches that relates to
this. ArrayList seems only to work for unidimensional arrays, while
Array.CreateInstance requires that I know the array size before
populating it (which a datareader can't give me).
I'd sure appreciate any help!
--Brent
multi-dimensional array of n length out of a DataReader loop. Take this
pseudo-code:
=======================================
public string[,] get_array(string sql)
{
//create db connection & open
string[,] arrReturn = new String[,];
SqlDataReader dataReader = myCommand.ExecuteReader();
if (dataReader.HasRows)
{
while (dataReader.Read())
{
//next line I don't know what to do!
arrReturn.AddToArray = {dataReader[0].ToString(),
dataReader[1].ToString()};
}
}
myConn.Close();
return arrReturn;
}
========================================
I can't seem to find anything in my Google searches that relates to
this. ArrayList seems only to work for unidimensional arrays, while
Array.CreateInstance requires that I know the array size before
populating it (which a datareader can't give me).
I'd sure appreciate any help!
--Brent