#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    VC++6 and MySQL++


    This was posted in the MySQL forum but I was told it might be better off here. So here's the post again.

    I have seen this code posted before on here and other websites.

    #include <stdio.h>
    #include <mysql++.h>

    #define host "localhost"
    #define username "db_username"
    #define password "db_password"
    #define database "db"

    MYSQL *conn;
    int main()
    {
    conn = mysql_init(NULL);
    mysql_real_connect
    (conn,host,username,password,database,0,NULL,0);
    MYSQL_RES *res_set;
    MYSQL_ROW row;
    unsigned int i;

    mysql_query(conn,"SELECT * FROM users WHERE
    userid=1");
    res_set = mysql_store_result(conn);
    unsigned int numrows = mysql_num_rows(res_set);
    while ((row = mysql_fetch_row(res_set)) != NULL)
    {
    for (i=0; i<mysql_num_fields(res_set); i++)
    {
    printf("%s\n",row[i] != NULL ? row[i] : "NULL");
    }
    }
    mysql_close(conn);
    return 0;
    }

    When I try to compile it I get this error.
    fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory

    I have placed the library into my Visual C++ Lib directory as well as copied all of the include files into my VC++ Includes directory and specified to link in MySQL++.lib

    The error is pointing into the file defs.h where it is trying to include <mysql.h>.

    Obviously it's not locating that include file but I'm not sure if I can just find the file and include it somewhere or if I missing something else here.

    TIA,
    Webby
  2. #2
  3. pogremar
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    At Work
    Posts
    958
    Rep Power
    13
    if you wanna include any file(you might already know this) you can dump it in the project directory where you have the other source files and do
    #include "file.h"
    Notice the double quotes instead of <...>
    I don't know if the Mysql stuff includes DLL's, but if they do, don't forget to add them to your environment path. I think it's in options>settings>c/c++ tab , not 100% sure though.

IMN logo majestic logo threadwatch logo seochat tools logo