X-Original-To: pgsql-interfaces@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DE6A1475AE5 for ; Thu, 10 Apr 2003 03:07:20 -0400 (EDT) Received: from mail024.syd.optusnet.com.au (mail024.syd.optusnet.com.au [210.49.20.148]) by postgresql.org (Postfix) with ESMTP id 911B6474E42 for ; Thu, 10 Apr 2003 03:07:18 -0400 (EDT) Received: from macros (c18553.sunsh2.vic.optusnet.com.au [198.142.132.148]) by mail024.syd.optusnet.com.au (8.11.6p2/8.11.6) with ESMTP id h3A774018415; Thu, 10 Apr 2003 17:07:14 +1000 From: "Matt Fitzgerald" To: "'Michiel Lange'" , Subject: Re: Getting to learn libpqxx Date: Thu, 10 Apr 2003 17:06:14 +1000 Message-ID: <000a01c2ff2f$b72d99c0$0000fea9@macros> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: <5.1.0.14.0.20030410001937.00b38370@192.168.1.3> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-5.9 required=5.0 tests=BAYES_20,FROM_ENDS_IN_NUMS,IN_REP_TO,MSGID_OE_SPAM_4ZERO, ORIGINAL_MESSAGE,RCVD_IN_NJABL,RCVD_IN_OSIRUSOFT_COM version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/58 X-Sequence-Number: 3997 Ok... some stupid questions: 1. I take it pqxx/connection.h is in the include path? 2. If so, what command are you using to compile the source? Also, your connection string is not built correctly, 'connstring' is not a class, thus it doesn't support any overloaded operators such as '<<' & '+' etc. Do some thing like this: #include std::stringstream connstring; connstring << "host=3D" << host << "database=3D" << dbase << "username=3D" = << uname << "password=3D" << passwd; // call connection constructor something like this: Connection *db =3D new Connection(connstring.str().c_str()); Etc.. etc.. also, as 'bool Immediate' defaults to 'true' you don't have to specify it. Regards, -Matt -----Original Message----- From: pgsql-interfaces-owner@postgresql.org [mailto:pgsql-interfaces-owner@postgresql.org] On Behalf Of Michiel Lange Sent: Thursday, 10 April 2003 8:31 AM To: pgsql-interfaces@postgresql.org Subject: [INTERFACES] Getting to learn libpqxx Hello everybody again, I went out to investigate and try if I could master libpqxx, for libpq++=20 works not at all. Seeing it is discontinued, and people are encouraged to= =20 use libpqxx, I was so bold as to try that ;-) Only to discover that there is hardly any documentation on how to access=20 stuff... now I, myself am more a C-programmer, and I know C++ is pretty=20 much different... it is really hard for me to think in classes and stuff,= =20 to think object-oriented... So, now you know I am an earthling :P I tried this kind of approach, the idea was to start out simple... so don't= =20 laugh at the attempt ... #include int main(int argc, char *argv[]) { Connection *db; char uname[250]; // username char passwd[250]; // password char host[250]; //hostname char passwd[250]; //password char dbase[250]; //database name char connstring[1264]; ... some output and input to get values for all these char arrays... connstring =3D "host=3D" >> host >> "database=3D" >> dbase >> "username=3D" >>=20 uname >> "password=3D" >> passwd; db =3D new Connection(connstring,true); if(db->is_open()) { cout << "Connection succesful!" << endl; cout << db->Options(); } else { cout << "Something went wrong... oops" << endl; } delete db; return 0; } I get my first errors at "Connection *db" declaration... there is no=20 Connection defined... Can anyone point out how to reference the classes libpqxx has? Also I was curious if my connstring was correctly built, but that is=20 another subject I think... One other very important thing would be: how can= =20 I find out the error PostgreSQL will throw at me when I did something ugly?= =20 At least I can find out the problem, when I make one then... Michiel ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org