Re: PGExec returns error without any comment
От | erkan kolemen |
---|---|
Тема | Re: PGExec returns error without any comment |
Дата | |
Msg-id | 20060928183309.11634.qmail@web58308.mail.re3.yahoo.com обсуждение исходный текст |
Ответ на | PGExec returns error without any comment (erkan kolemen <erkankolemen@yahoo.com>) |
Список | pgsql-interfaces |
Thanks,<br /><br />That was the problem!<br /><br /><b><i>Volkan YAZICI <yazicivo@ttnet.net.tr></i></b> wrote:<blockquoteclass="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> OnSep 28 05:16, erkan kolemen wrote:<br />> char *conninfo;<br />> PGconn *conn;<br />> PGresult *res;<br />><br />> /* Prepare connection info */<br />> conninfo = (char *) malloc(64);<br />> if (conninfo == NULL){<br />> fprintf(stderr, "malloc error: %s\n", strerror(errno));<br />> return -1;<br />> }<br />> <br />>memset(conninfo, 0, 64);<br />> strncpy(conninfo, "dbname=llist user=yyy password=xxx", 63);<br /><br />I'd prefera<br /><br /> char conninfo[] = "dbname=llist user=yyy password=xxx";<br /><br />instead of above mess.<br /><br />>/* Make a connection to the database */<br />> conn = PQconnectdb(conninfo);<br />> <br />> /* Check to seethat the backend connection was successfully made */<br />> if (PQstatus(conn) != CONNECTION_OK)<br />> {<br />>fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(conn));<br />> return -1;<br />> }<br />><br />> res = PQexec(conn, "select * from lists;");<br />> if (PQresultStatus(res) != PGRES_COMMAND_OK)<br /><br/>You should be checking for PGRES_TUPLES_OK, not COMMAND_OK.<br /><br />AFAIU from your name, you're from Turkey. Haveyou ever heard about<br />"PostgreSQL ile Programlama" book? You can get it freely from here:<br />http://www.students.itu.edu.tr/~yazicivo/doc/postgresql-ile-programlama.html<br/><br /><br />Regards.<br /></blockquote><br/><p><hr size="1" /><a href="http://us.rd.yahoo.com/evt=43256/*http://advision.webevents.yahoo.com/mailbeta">All-new Yahoo! Mail </a>- Fire up amore powerful email and get things done faster.
В списке pgsql-interfaces по дате отправления: