没怎么用过VC连接数据库,对很多概念不时很熟悉,求各位大虾,能发发慈悲,尽量详细的介绍下方法.一步一步来啊!!

解决方案 »

  1.   

    http://www.google.com.sg/#hl=en&newwindow=1&biw=1259&bih=819&q=VC+postgresql&aq=f&aqi=&aql=&oq=&fp=e871449940a31f1a
      

  2.   

    #include “stdafx.h”
    #includechar * string_for_query;;
    PGconn *Conn_pointer;
    PGresult *result;char* pghost = “localhost”; //IP address string is also ok
    char* pgport =”5432″;
    char* pgoptions =NULL;
    char* pgtty = NULL;
    char* dbName = “school”;
    char* username = “postgres”; //postegres is the username that
    char* password = “123456″ ;//set when insalled cannot get directly#pragma comment(lib,”C:\\Program Files\\PostgreSQL\\8.3\\lib\\libpq.lib”)
    int main()
    {
    Conn_pointer=PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, username, password);
    if (PQstatus(Conn_pointer) == CONNECTION_BAD)
    {
    printf(“cannot connect to the database!\n”);
    return -1;
    }
    printf (“Connect to database seccess\n”);
    return 0;
    }
      

  3.   

    在这个层次上不区分 vc 还是什么 c.
      

  4.   

    运行时出现没有找到LIBPQ.dll,但是文件的确就在那个目录下啊。