2008-03-21, 10:21 PM 
	
	
	zehd Wrote:In the above example, I use a generic .getvalue that will take whatever type the data is and then it goes into a string. I suppsoe I could start to use specific datatypes. I know that VB6 is notorious for being slow when using variants. What do you all suggest?I prefer to stick with real data types.
Quote:Also, I'd like to pump the results into an array. Is it correct to grab each column of each line, like this and add to array, or is there a way to get the query results already in a two dimensional array...You could do something like this...
Declare some class to hold the various attributes:
Code:
public class Genre
{
   public int oid;
   public string genreName;
   public unsigned int argb;
}then create a list and populare a instance of that class each time around the loop...
Code:
ArrayList genreList = new ArrayList();
 
    // load list of genre codes
    DbCommand command = dbProviderFactory.CreateCommand();
    command.Connection = connection;
    command.CommandText = "SELECT * from GENRE";    
    DbDataReader dataReader = command.ExecuteReader();
    while (dataReader.Read())
    {
        // create new instance
        Genre myGenre= new Genre();
 
        // load object from database settings        
        myGenre.oid = dataReader.GetInt32(dataReader.GetOrdinal("oid"));
        myGenre.name = dataReader.GetString(dataReader.GetOrdinal("genre_name"));
        .... etc
        // add object to list
        genreList.Add(myGenre);
    }
    dataReader.Close();At the end of this you'd have a list of all the genre objects in the database.
 



