List:MySQL++« Previous MessageNext Message »
From:Dr. BVLS Prasad Date:May 14 2007 7:06pm
Subject:whats wrong with this simple1.cpp code:
View as plain text  
Hi ,
    I just started learning mysql++.
    I opened the simple1.cpp and tried playing with it.

    This is the Code:
   // The only modification is : Avoiding connect_db function and
removing the util files
  // from the code. Using the Connection con - directly.
******************************************************************************************
#include <mysql++.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char **argv)
{
        // Connect to the sample database.
        //(argv[4]= database, argv[3]=password, argv[2] = user ,argv[1] = host;
        mysqlpp::Connection con(argv[4], argv[1], argv[2],argv[3]);

        // Retrieve a subset of the sample stock table set up by resetdb
        mysqlpp::Query query = con.query();
        query << "select prot_id from prot";
        mysqlpp::Result res = query.store();

        // Display the result set
        cout << "We have:" << endl;
        if (res) {
                mysqlpp::Row row;
                mysqlpp::Row::size_type i;
                for (i = 0; row = res.at(i); ++i) {
                        cout << '\t' << row.at(0) << endl;
                }
        }
        else {
                cerr << "Failed to get item list: " << query.error() <<
endl;
                return 1;
        }

        return 0;
}
***************************************************************************
It compiled, linked properly. It has shown the results and abruptly died with
an error:
*************************************************************************************
[prasad@master examples]$ ./a.out localhost udata upass practice
We have:
        1315
        281887
        281902
        281945
        281947
        281948
        281958
        282000
        282010
        282020
        282039
        282040
        282041
        282046
        282047
        282055
        282080
        282087
        282088
        282092
terminate called after throwing an instance of 'mysqlpp::EndOfResults'
  what():  end of results
Aborted
[prasad@master examples]$
*********************************************************************************
What instruction did I forget? where am I wrong?
Thank you very much.
Prasad.
Thread
whats wrong with this simple1.cpp code:Dr. BVLS Prasad14 May
  • RE: whats wrong with this simple1.cpp code:Jim Wallace14 May
    • RE: whats wrong with this simple1.cpp code:Ian Daysh15 May