Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 7 của 7
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Nếu cậu lập trình C++ CLI/.NET thì Dùng ADO.NET;
    Nếu cậu lập trình C++ ANSI/ISO thì dùng OBDC Component.

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    em dùng ANSI thui,anh chỉ rõ hộ em OBDC Component là bao gồm những thứ gì không,cho em xin cái tên phần mềm [IMG]images/smilies/biggrin.png[/IMG],

    VD nhưđoạn code này em không tìm được file mysql.h nó nằm ở đâu( mặc dù em đã cài MYSQL ) hoặc là em chỉ cài mỗi bộ cài mà không cài phần develop cho nó,nếu anh có kinh nghiệm có thể chỉ em nên cài bộ cài để develop MYSQL không

    Mã:
    // example file hellow/main.c
    #include <stdio.h>
    #include <mysql.h> // functions from libmysqlclient
    int  main(int argc, char *argv[])
    {
        int i;
        MYSQL *conn; // connection
        MYSQL_RES *result;   // result of the SELECT query
        MYSQL_ROW row;  // a record form the SELECT query
        // create connection to MySQL
        conn = mysql_init(NULL);
        if(mysql_real_connect(
        conn, "localhost", "root", "XXX",
        "mylibrary", 0, NULL, 0) == NULL) {
      fprintf(stderr, "sorry, no database connection  . . .    
    ");
      return 1;
            }
        // create list of all publishers and determine number
        // of published titles
        const char *sql="SELECT COUNT(titleID), publName \
                         FROM publishers, titles \
                         WHERE publishers.publID = titles.publID   \
                         GROUP BY publishers.publID \
                         ORDER BY publName";
        if(mysql_query(conn, sql)) {
            fprintf(stderr, "%s
    ", mysql_error(conn));
            fprintf(stderr, "%s
    ", sql);
            return 1;
        }
        // process result
        result = mysql_store_result(conn);
        if(result==NULL) {
            if(mysql_error(conn))
      fprintf(stderr, "%s
    ", mysql_error(conn));
            else
      fprintf(stderr, "%s
    ", "unknown error
    ");
            return 1;
        }
        printf("%i records found
    ", (int)mysql_num_rows(result));
        // loop over all data records
        while((row = mysql_fetch_row(result)) != NULL) {
            for(i=0; i <  mysql_num_fields(result); i++) {
      if(row[i] == NULL)
        printf("[NULL]\t");
      else
        printf("%s\t", row[i]);
            }
            printf("
    ");
        }
        // release memory, break connection
        mysql_free_result(result);
        mysql_close(conn);
        return 0;
    }

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    http://mysqlcppapi.sourceforge.net/
    Nếu cậu xài mySql Library này rồi thì thôi khỏi OBDC làm gì nữa, người ta thiết kế mySQL library này dùng riêng cho MYSQL, có lẽ là rất ỗn định
    Tui nghĩ link trên là Download Thữ viện và header file để cậu lập trình trên C/C++ AnSI đó, Tui chưa down thử. Chỉ kiếm giúp cậu thôi.
    Còn link nữa hầu hết là dùng cho hệ điều hành Linux http://tangentsoft.net/mysql++/, nhưng tui cũng có thấy mục Visual C++ trong đó.

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    đây là kết quả OK


    Mã:
    // example file hellow/main.c#include <Windows.h>#include <stdio.h>#include <mysql.h> // functions from libmysqlclient int  main(int argc, char *argv[]){    int i;    MYSQL *conn; // connection    MYSQL_RES *result;   // result of the SELECT query    MYSQL_ROW row;  // a record form the SELECT query    // create connection to MySQL    conn = mysql_init(NULL);    if(mysql_real_connect(        conn, "localhost", "root", "XXX",        "mylibrary", 0, NULL, 0) == NULL) {            fprintf(stderr, "sorry, no database connection  . . .    
    ");            return 1;    }    // create list of all publishers and determine number    // of published titles    const char *sql="SELECT COUNT(titleID), publName \[*]                    FROM publishers, titles \                    WHERE publishers.publID = titles.publID   \                    GROUP BY publishers.publID \                    ORDER BY publName";    if(mysql_query(conn, sql)) {        fprintf(stderr, "%s
    ", mysql_error(conn));        fprintf(stderr, "%s
    ", sql);        return 1;    }    // process result    result = mysql_store_result(conn);    if(result==NULL) {        if(mysql_error(conn))            fprintf(stderr, "%s
    ", mysql_error(conn));        else            fprintf(stderr, "%s
    ", "unknown error
    ");        return 1;    }    printf("%i records found
    ", (int)mysql_num_rows(result));    // loop over all data records    while((row = mysql_fetch_row(result)) != NULL) {        for(i=0; i <  mysql_num_fields(result); i++) {            if(row[i] == NULL)                printf("[NULL]\t");            else                printf("%s\t", row[i]);        }        printf("
    ");    }    // release memory, break connection    mysql_free_result(result);    mysql_close(conn);    return 0;}

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    ở đây có hướng dẫn
    http://www.codeproject.com/KB/database/mysqlwrap.aspx
    có điều tui thử lục tung các lib chả thấy cái mysql.h nó ở đâu cả

    một số link đã down
    http://mysql.phphosts.org/Downloads/...n32-vs2005.zip
    http://tangentsoft.net/mysql++/relea...+-3.0.9.tar.gz

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    à biết tại sao rồi,đây là nguyên nhân
    http://forums.mysql.com/read.php?45,...540#msg-194540

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •