Обсуждение: problem connecting with libpq++ interface
Hi everybody,
I have a really strange problem . I'm trying to connect to PostgreSQL db
from witin my C++ program and using the libpq++ interface functions . But
strangely it won't connect and I'm receiving the following error message
connection to db failed.
Error returned:ERROR: PQconnectdb() - Missing '=' after 'template1' in
conninfo
.here's my code
PGconn *conn1;
const char * dbname="template1";
PgDatabase data(dbname);
conn1=PQconnectdb(dbname);
if (data.ConnectionBad())
{
cerr<<" connection to db failed."<< endl
<<" Error returned:" << data.ErrorMessage() << endl;
exit(1);
}
any idea would be appreciated. thanks in advance!
deniz
"Deniz Hastorun" <denizh@itu.edu.tr> writes: > Error returned:ERROR: PQconnectdb() - Missing '=' after 'template1' in > conninfo PQconnectdb doesn't take a simple database name as argument; it takes a string containing keyword=value pairs. The correct argument would be something like "dbname=template1". See http://www.postgresql.org/users-lounge/docs/7.0/postgres/libpq-chapter.htm#AEN22236 If you see anyplace in current documentation that indicates differently, that's a documentation error --- please let us know about it! regards, tom lane