Article View: fr.comp.os.ms-windows.programmation
Article #14Help !! Prog C++ pour connection MYSQL
From: Makmaze
Date: Sun, 17 Mar 2002 21:23
Date: Sun, 17 Mar 2002 21:23
69 lines
3040 bytes
3040 bytes
Bonjour,
j'esp�re avoir post� ce message dans les bon newsgroups, d�sol� si ce
n'est pas le cas.
Je dois r�alis� un programme en C++ sous Windows NT pour me connecter
� une base de donn�e qui tourne sous MYSQL.
J'utilise donc la dll fournie avec MYSQL � savoir "libmySQL.dll", mais
j'ai quelques probl�mes. Je n'arrive pas � utiliser les fonctions de
cette DLL, d�s le lancement du programme, j'ai un "acces violation".
Je poste ce petit bout de code qui est cens�s me connecter au serveur
MYSQL. Quand je le lance, je constate que ma connexion est active mais
le programme plante instantan�ment.
Quelqu'un a une id�e ? Je mis prend peux �tre n'importe comment, mais
l� je vois pas.
-----------------------------------
#include "Mysql.h"
#include "Windows.h"
class base_donne
{
private :
MYSQL *my ;
HINSTANCE ID_DLL ;
MYSQL* (* ptr_init)(MYSQL *);
MYSQL* (* ptr_connection)(MYSQL *, const char *, const
char*, const char *,const char *, unsigned int , const char*, unsigned
int );
public :
base_donne();
void connection_bdd();
};
base_donne::base_donne()
{
ID_DLL = LoadLibrary("libmySQL.dll");
ptr_init = (MYSQL* (*)(MYSQL
*))GetProcAddress(ID_DLL,"mysql_init");
ptr_connection = (MYSQL* (*)(MYSQL *, const char *, const
char*,const char *, const char *, unsigned int , const char *,
unsigned int ))GetProcAddress(ID_DLL, "mysql_real_connect");
}
void base_donne::connection_bdd()
{
my = ptr_init((MYSQL*) 0);
ptr_connection(my,"192.168.0.242","login","mot_de_passe","base_de_donne",MYSQL_PORT,0,0);
}
main()
{
base_donne mabase;
mabase.connection_bdd();
}
-----------------------------------
Merci � ceux qui voudrons bien me r�pondre.
--
Makmaze
Tousse pour un, rhume pour tous
Technical Details
Message-ID:
<m21a9ucnc6bo98evnh2m29emgnb7ik2em6@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!fr.clara.net!heighliner.fr.clara.net!proxad.net!feeder2-1.proxad.net!news1-2.free.fr!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII X-Google-Thread: ffbfc,fb5b11797bbb0e9a,start X-Google-Attributes: gidffbfc,public X-Google-Thread: 1053e6,fb5b11797bbb0e9a,start X-Google-Attributes: gid1053e6,public X-Google-Thread: fdcad,fb5b11797bbb0e9a,start X-Google-Attributes: gidfdcad,public X-Google-ArrivalTime: 2002-03-17 13:21:10 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!fr.clara.net!heighliner.fr.clara.net!proxad.net!feeder2-1.proxad.net!news1-2.free.fr!not-for-mail From: Makmaze <makmaze@invalid.com> Newsgroups: fr.comp.os.ms-windows.programmation,fr.comp.lang.c++,fr.comp.applications.sgbd Subject: Help !! Prog C++ pour connection MYSQL Date: Sun, 17 Mar 2002 22:23:12 +0100 Reply-To: makmaze@free.fr Message-ID: <m21a9ucnc6bo98evnh2m29emgnb7ik2em6@4ax.com> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Lines: 69 Organization: Guest of ProXad - France NNTP-Posting-Date: 17 Mar 2002 22:21:09 MET NNTP-Posting-Host: 62.147.83.19 X-Trace: 1016400069 news1-2.free.fr 3183 62.147.83.19 X-Complaints-To: abuse@proxad.net