Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //To make use in C/C++, you include these header files
- #include "libpq/libpq-fs.h"
- #include "libpq-fe.h"
- #include <stdlib.h>
- #include <string.h>
- #include <conio.h>
- //Declare some variables
- const char *conninfo;
- PGconn *conn;
- PGresult *preslt;
- //Connect to DB
- conninfo = "dbname = lebl user=postgres password=abcd1234@";
- /* Make a connection to the database */
- conn = PQconnectdb(conninfo);
- /* Check to see that the backend cfonnection was successfully made */
- if (PQstatus(conn) != CONNECTION_OK)
- {
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
- PQfinish(conn);
- }
- else
- {
- printf("Connection Ok");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement