mysql_real_connect problem!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jasper

    #1

    mysql_real_connect problem!

    Hi All

    Iam using the libmysql.lib in my C++ app, I have a mySQL database setup on a
    remote server something.dyndn s.org and using port 2000, I use the following
    little bit of code to try and access the database but it just sits there and
    does nothing. Iam I doing something wrong, not doing something or is there a
    problem using libmysql with a C++ app. Any help would be great.

    #include <windows.h>
    #include <winsock2.h>

    #pragma warning (disable: 4514 4786)
    #pragma warning( push, 3 )
    #define VERSION "4.1"
    #endif

    #pragma comment(lib, "libmysql.l ib")

    // SQL test
    #include <MySQL.h>

    void MySQLTest(void)
    {
    MYSQL *mysql = NULL;
    MYSQL *connect = NULL;
    //int timeout = 4;

    mysql = mysql_init(NULL );

    //mysql_options(m ysql, MYSQL_OPT_CONNE CT_TIMEOUT, (const char *)&timeout);

    connect = mysql_real_conn ect(mysql, "something.dynd ns.org", "root", NULL,
    "mysql", 2000, NULL, 0);

    if ( !connect )
    {
    // Had a problem
    Debug(("Failed to connect to database: Error: %s<br>\n",
    mysql_error(mys ql)));
    }
    else
    {
    Debug(("We connected to the SQL database<br>\n" ));
    }

    mysql_close(mys ql);
    }



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.648 / Virus Database: 415 - Release Date: 31/03/2004


  • Aggro

    #2
    Re: mysql_real_conn ect problem!

    Jasper wrote:
    [color=blue]
    > mysql = mysql_init(NULL );[/color]

    I don't bulieve the problem is here, but you should check the return
    value from mysql_init to make sure it is not NULL (which means error).

    Comment

    • Aggro

      #3
      Re: mysql_real_conn ect problem!

      Jasper wrote:
      [color=blue]
      > mysql = mysql_init(NULL );[/color]

      I don't bulieve the problem is here, but you should check the return
      value from mysql_init to make sure it is not NULL (which means error).

      Comment

      Working...