I am working on a replacement GINA (Graphical Identification and
Authentication) for the University I work for.  It is a DLL written in C
and I need to add mysql connectivity to it.

 

I am writing this in Visual Studio 2003.  It took me forever to get all
the MySQL API's libs to link correctly but I finally have a fully
functioning version of a simple program that connects to the database.
I would like all of the connectivity info (user, pass, etc.) to be found
in the my.ini file.  According to the API docs this is possible and
simple.  But it is not working.  I even found an old list item that
gives an example (and it almost matched my code exactly) that is
supposed to work.

 

Here is my code:

 

#include "stdafx.h"

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

 

 

 

 

 

int _tmain(int argc, _TCHAR* argv[])

{

      MYSQL mysql;

 

      mysql_init(&mysql);

      mysql_options(&mysql,MYSQL_READ_DEFAULT_FILE,"./my.ini");

      mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"MYSQL-API");

      if (!mysql_real_connect(&mysql,NULL, NULL, NULL, NULL, 0, NULL,
0))//&mysql,"chilton.byu.edu","liil","itsgr8$you","machine",0,NULL,0))

      {

            fprintf(stderr, "\nFailed to connect to database: Error:
%s\n\n",

          mysql_error(&mysql));

      }

      else printf("\nConnected to database!!\n\n");

      

      mysql_close(&mysql);

      return 0;

}

 

 

And here is my.ini

                              

[MYSQL-API]

user='user'

password='**********'  

Server='chilton.***.edu'

database='machine'

 

 

the * are there for the purpose of this email only.  I have tried the
data with and without the single quotes.

 

Here is the error I receive :

Failed to connect to database: Error: Can't connect to MySQL server on
'localhost' (10061)

 

It appears to be trying to connect at least but it is not getting the
user name.

 

If I replace the 'null' in the code with the actual data it connects
just fine.

 

According to everything that I have read this should work.  Any ideas?

 

Thanks

 

Dan

 

Reply via email to