>>>>> "Ray" == Ray Akey <rakey@stripped> writes:
Ray> I am having problems with mySQL and developing a win32 client application
Ray> under Microsoft Visual C++ 5.
Ray> Here is what is happening:
Ray> I allocate a MYSQL handle of size sizeof(MYSQL).
Ray> I then perform a mysql_real_connect() with the appropriate arguments.
Ray> The problem is that the current object pointer (this) is being trashed and
Ray> its window handle is trashed also..
Ray> Here is the code that causes the problem. It is a snippet from a dialog
Ray> In the code below, cData has bee previously allocated using malloc().
Ray> If I remove (comment out) the mysql_real_connect() call, things work fine.
Ray> // cData is allocated and initalized as follows:
Ray> cData = malloc(sizeof(MYSQL));
Ray> memset(cData, 0, sizeof(MYSQL));
Ray> // up to here,, the "this" pointer and the window handle are ok..
Ray> if(mysql_real_connect( cData, "192.168.0.3", "ray", "mypassword",
Ray> MYSQL_PORT, NULL, 0))
Ray> // here is where the problem occurs..
Ray> // as the "this" pointer is altered and the current window handle becomes
Ray> CDialog::OnOK(); // If connect successful, call CDialog::OnOK()
Ray> // otherwise call CDialog::OnCancel()
Ray> Has anyone ese had problems of this sort with mySQL under win32? Is there a
Ray> problem with libmysql.lib?
I have now tested your problem with both the shareware version and the
registered version (You can find the libs from the registered MySQL
version at http://www.mysql.com/download_win.html).
Both version worked without any problems for me!
I noticed that you did never even try the newer libs from the
registered version (as you had the wrong number of arguments to
mysql_real_connect()), even if I earlier suggested that you should
have used these.
At any rate, I recommend you to use the newer libs as these has new
features that can be used against newer MySQL servers but they will
also work with an old server without any problems!
The problem you where facing was probably that you had included the
wrong types of standard libraries with your application!
You should use the 'multithreaded' or 'multhreaded-debug' version of
The following zip file includes a corrected version of your program
that works both with the shareware libs and the newer libs. I have
also included makefiles for both version so that you can check what I
did (and hopefully repeat it)
PS: If you had included a project file with your test, I would have
been able to test this MUCH faster!