mercredi 4 octobre 2017

How to use list array in C++

I am getting the list of brands from sqlite3 database,you can see in BrandCodes function, I have written new function Brands(), I don't know how to assign BRCode and BRText to this result. Is this the right approach. Please help me, guys. I know how to use in C#.

SortedList *Util::BrandCodes()
{
    SortedList *list = new SortedList();

    IDbCommand    *command = 0;
    IDataReader *reader = 0;

    command = m_dbConnection->CreateCommand();
    command->CommandText = S"SELECT * FROM BrandData";
    reader = command->ExecuteReader();
            // Read all records
    while( reader->Read() )
    {
        // Add item to the map [ market_id, description ]
        list->Add( reader->Item[ S"BRCode" ]->ToString(),
        String::Format(S"{0}({1})",GetFieldValue(reader,S"BRText"),GetFieldValue(reader,S"BRCode")));
    }
    Brands();
    return list;
}

String *FuelUtil::Brands( ) __gc[]
{
    String *result __gc[];
    result = 0;
    SortedList  *brandList = 0;

    if (brandList == 0)
    {
        brandList = GetBrandCodes();            
    }       

    for (int i =0; i<= brandList->Count; i++)
    {
        result = new String * __gc[2];
        // how to assign BRCode and BRText to this result
        //result[0] = 
        //result[1] = 
    }

    return result;
}

Aucun commentaire:

Enregistrer un commentaire