Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    30

    Unanswered: ListBox and Table Values

    Hi

    got small problems with the table values. I got three rows in a table

    Index (int)
    Product (varchar)
    Price (float)

    I could successfully connect to the database. I also get the values but somehow the ListBox don't show them....


    Anyone can help me please ?


    CODE

    {
    CDBVariant value;
    char sql_statement [2048] = "";

    //CDatabase object "db" created to connect database
    CDatabase db;
    db.OpenEx(_T("DSN=Beauty"),CDatabase::noOdbcDialog );

    //CRecordset object "rs" created to access and manipulate database records.
    CRecordset rs(&db);
    strcpy(sql_statement,_T("SELECT * FROM TestTabelle"));
    rs.Open(CRecordset::forwardOnly,sql_statement);

    //Get quantity from Database
    int n = rs.GetODBCFieldCount( );

    while(!rs.IsEOF())
    {
    for( int i = 0; i < n; i++ )

    {
    rs.GetFieldValue("index",value);
    m_Buy_List.InsertItem(i,LPCTSTR(value.m_lVal));

    rs.GetFieldValue("product",value.m_pstring);
    m_Buy_List.SetItemText(i,2,LPCTSTR(value));

    rs.GetFieldValue("price",value);
    m_Buy_List.SetItemText(i,3,LPCTSTR(value.m_fltVal) );


    rs.MoveNext( );
    }
    }
    Last edited by Indian; 09-30-03 at 08:44.

  2. #2
    Join Date
    Dec 2002
    Posts
    29
    This is a VC++ code problem, I presume. Probably you should try some VC++ forums, for ex: www.codeguru.com

    Best regards!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •