Link to home
Start Free TrialLog in
Avatar of HMoellendorf
HMoellendorfFlag for Germany

asked on

mySQL Connection - How to get it working?

Hi there.

I've just downloaded
http://tangentsoft.net/mysql++/

But I don't know, what I have to do now.
Could someone give me a short statement?

Thanks
Henning
Avatar of lakshman_ce
lakshman_ce

Look at the tutorial chapter of the user manual
http://tangentsoft.net/mysql++/doc/userman/html/index.html
Avatar of AndyAinscow
But I don't know, what I have to do now.
Could someone give me a short statement?

Er?  (Is that short enough?)

Seriously.  What do you want to know?
Avatar of HMoellendorf

ASKER

I don't know, how to import the libmysql.dll!
SOLUTION
Avatar of lakshman_ce
lakshman_ce

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay, I've now added to the dependencies the libmysql.lib file.
The script is now running.

But how do I now access the Functions of libmysql?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi folks,

now it works so far:

I can open a connection.
But I want to write a class, which manages the db-connection.

But I don't know, how I make MYSQL *conn; working class-wide.

Henning
Additional, It works.
But I can't output the value of a field in a MessageBox.

The command:

MessageBox(NULL, (char) "Test", TEXT("TEst"), MB_OK);      
The error, errorcode: C2664:

Konvertierung des Parameters 2 von 'char' in 'LPCWSTR' nicht möglich
Conversion of Parameter 2 from 'char' to 'LPCWSTR' not possible.

Can someone help me?
Looks like you might be building with Unicode support - was that your intention?
I dunno.

I need to output the content of the rows.
But I don't get it.

Do you know, why?
Can you post what you've got so far (if it isn't too long; if it is then try to post the bare minimum to get your point across)
#CODE BEGIN

#include "stdafx.h"
#include "stdio.h"
#include "windows.h"

#include "dbmanager.h"


database_manager::database_manager() {

      mySqlPointer = NULL;

}

database_manager::~database_manager() {

      mysql_close(mySqlPointer);

}

bool database_manager::connect() {

      mySqlPointer = mysql_init(NULL);
      if(mysql_real_connect(mySqlPointer, "HOST", "USER", "PASS", "DB", 3306, NULL, 0)) {
            return true;
      }
      else
      {
            return false;
      }
}

int database_manager::doQuery(const char *query) {
      
      int res;
      if(mysql_query(mySqlPointer, "SELECT * FROM ij_user"))
      {
            
            MessageBox(NULL, TEXT("Fehler"), TEXT("Test"), MB_OK);
            
      }
      else
      {
            unsigned int num_fields;
            unsigned int i;

            mySqlRes = mysql_use_result(mySqlPointer);
            num_fields = mysql_num_fields(mySqlRes);
            while(mySqlRow = mysql_fetch_row(mySqlRes)) {
                  for(i = 0; i < num_fields; i++) {
                        MessageBox(NULL, (LPCWSTR) mySqlRow[i], TEXT("Test"), MB_OK);                  
                  }
            }
      }
      return 1;

}
#END CODE

The result is now many squares, but no real data...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial