1 message in com.mysql.lists.plusplusEnquiry part 2
FromSent OnAttachments
Octavio Rojas03 Sep 2000 08:33 
Subject:Enquiry part 2
From:Octavio Rojas (roj@hotmail.com)
Date:09/03/2000 08:33:57 AM
List:com.mysql.lists.plusplus

Hi:

Following is a copy of the code I am trying to run. The reasons for the changes over simple1.cc are as follows: a.) I entered mysql and found that mysql_cpp_data was not amongst the databases. b.) The alternative code that apears as a comment to the example gives a compilation error (it states that the syntaxis does not match the available overloaded options).

So far, I have still not found the reset-db (command?) that figures in the online manual.

All I know is that every time I run it it ABORTS.

The above, places me in a position that I do not know if: a.) The code is wrong. b.) Unless I run the reset-db, I will not be able to run the program. c.) Both of the above apply.

Thanks in advance for your help.

Regards,

Octavio Rojas-Mujica

#include <iostream> #include <iomanip> #include <sqlplus.hh>

const char *FileName="Try"; const char *host="[HOSTNAME]"; const char *user="[USERNAME]"; const char *passwd="[PASSWORD]";

int main() { // Connection con("mysql_cpp_data");

Connection con(use_exceptions); con.connect(FileName,host,user,passwd);

// The full format for the Connection constructor is // Connection(cchar *db, cchar *host="", // cchar *user="", cchar *passwd="") // You may need to specify some of them if the database is not on // the local machine or you database username is not the same as your // login name, etc..

Query query = con.query(); // This creates a query object that is bound to con.

query << "select * from First"; // You can write to the query object like you would any other ostrem

Result res = query.store(); // Query::store() executes the query and returns the results

cout << "Query: " << query.preview() << endl; // Query::preview() simply returns a string with the current query // string in it.

cout << "Records Found: " << res.size() << endl << endl;

Row row; cout.setf(ios::left); cout << setw(11) << "Position" << setw(30) << "Value" << endl << endl;

Result::iterator i; // The Result class has a read-only Random Access Iterator for (i = res.begin(); i != res.end(); i++) { row = *i; cout << setw(11) << row[0] << setw(30) << row["value"] // you can use either the index number or column name when // retrieving the colume data as demonstrated above. << endl; } return 0; }

Share information about yourself, create your own public profile at http://profiles.msn.com.