Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1318 connectés 

  FORUM HardWare.fr
  Programmation
  C

  c + mysql

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

c + mysql

n°1010311
fabien
Vive la super 5 !
Posté le 11-03-2005 à 23:25:52  profilanswer
 

Bonjour  :hello:  
 
Je voudrais faire une appli en c et je voudrais savoir comment il faut faire pour interagir avec la bdd mysql ? (conection, execution de requete, deconnection, recuperation des données, etc)
 
Je suis avec dev c++ , faut t'il rajouter une librairie mysql ?
 
je cherche de la doc, ou bien des explications si vous avez le temps. :jap:
 
merci d'avance :)
 


---------------
Découvre le HFRcoin ✈ - smilies
mood
Publicité
Posté le 11-03-2005 à 23:25:52  profilanswer
 

n°1010347
Emmanuel D​elahaye
C is a sharp tool
Posté le 12-03-2005 à 00:09:26  profilanswer
 

fabien a écrit :

Je voudrais faire une appli en c et je voudrais savoir comment il faut faire pour interagir avec la bdd mysql ? (conection, execution de requete, deconnection, recuperation des données, etc)
 
Je suis avec dev c++ , faut t'il rajouter une librairie mysql ?


Oui. Il y a un package à télécharger...


---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1010349
fabien
Vive la super 5 !
Posté le 12-03-2005 à 00:15:34  profilanswer
 

Emmanuel Delahaye a écrit :

Oui. Il y a un package à télécharger...


t'aurais un tuto qui explique comment installer la librairie mysql dans dev c++ ?  


---------------
Découvre le HFRcoin ✈ - smilies
n°1010353
Emmanuel D​elahaye
C is a sharp tool
Posté le 12-03-2005 à 00:18:32  profilanswer
 

fabien a écrit :

t'aurais un tuto qui explique comment installer la librairie mysql dans dev c++ ?


click click click... Pas grand chose à expliquer...  
 
Ca commence par
 
Aide / A propos ... / Nouvelle version
 


---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1010356
fabien
Vive la super 5 !
Posté le 12-03-2005 à 00:23:46  profilanswer
 

mais on le trouve ou ce package ?


---------------
Découvre le HFRcoin ✈ - smilies
n°1010360
Emmanuel D​elahaye
C is a sharp tool
Posté le 12-03-2005 à 00:28:57  profilanswer
 

fabien a écrit :

mais on le trouve ou ce package ?

Dans la liste...


---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1010392
fabien
Vive la super 5 !
Posté le 12-03-2005 à 00:58:39  profilanswer
 


j'ai aucune liste lorsque je vais dans tool/ about / update [:spamafote]


---------------
Découvre le HFRcoin ✈ - smilies
n°1010394
tet2neu
emmerdeur
Posté le 12-03-2005 à 01:00:35  profilanswer
 

C'est pas dans tool c'est dans help

n°1010409
fabien
Vive la super 5 !
Posté le 12-03-2005 à 01:07:15  profilanswer
 

tet2neu a écrit :

C'est pas dans tool c'est dans help


oué, je voulais dire help. en tous cas, je n'ai aucune liste de package :/


---------------
Découvre le HFRcoin ✈ - smilies
n°1010418
chrisbk
-
Posté le 12-03-2005 à 01:28:08  profilanswer
 

fabien a écrit :

Bonjour  :hello:  
 
Je voudrais faire une appli en c et je voudrais savoir comment il faut faire pour interagir avec la bdd mysql ? (conection, execution de requete, deconnection, recuperation des données, etc)
 
Je suis avec dev c++ , faut t'il rajouter une librairie mysql ?
 
je cherche de la doc, ou bien des explications si vous avez le temps. :jap:
 
merci d'avance :)


 
bin va voir la doc de de l'api C de mysql...

mood
Publicité
Posté le 12-03-2005 à 01:28:08  profilanswer
 

n°1010426
tet2neu
emmerdeur
Posté le 12-03-2005 à 01:50:30  profilanswer
 

Help / About / Check for updates / check for updates et la liste apparait
 
http://img216.exs.cx/img216/5245/mysql0sz.png
 
edit : je veux mes images :fou:


Message édité par tet2neu le 12-03-2005 à 01:52:22
n°1010429
fabien
Vive la super 5 !
Posté le 12-03-2005 à 01:55:31  profilanswer
 

ha ok, moi j'avais la vieille version de dev cpp :)
 
c'est quel version que tu as ?


Message édité par fabien le 12-03-2005 à 01:56:03

---------------
Découvre le HFRcoin ✈ - smilies
n°1010430
tet2neu
emmerdeur
Posté le 12-03-2005 à 01:56:41  profilanswer
 

4.9.9.1 :)

n°1010432
fabien
Vive la super 5 !
Posté le 12-03-2005 à 02:03:19  profilanswer
 

j'suis en train d'installer la 4.9.9.1 :)


---------------
Découvre le HFRcoin ✈ - smilies
n°1010433
tet2neu
emmerdeur
Posté le 12-03-2005 à 02:05:56  profilanswer
 

Evite de faire plein de mises à jour en même temps, c'est super lent :fou:  
Mais une MAJ toute seule ça va c'est rapide ;)


Message édité par tet2neu le 12-03-2005 à 02:06:14
n°1011451
fabien
Vive la super 5 !
Posté le 13-03-2005 à 19:28:58  profilanswer
 

bon j'ai installé une nouvelle version avec le package mysql, et maintenant ca me fait plein d'erreur sur mysql.h et les autres fichiers inclu:
 

gcc.exe "C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c" -o "C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.exe"    -I"include"   -L"lib"  
In file included from C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:57,
                 from C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:2:
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:116: error: syntax error before "SOCKET"
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:135: error: syntax error before '}' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:167: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:168: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:169: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:170: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:171: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:172: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:173: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:175: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:176: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:180: error: syntax error before "s"
 
In file included from C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:2:
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:168: error: syntax error before "NET"
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:205: error: syntax error before '}' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:214: error: syntax error before "MYSQL"
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:220: error: syntax error before '}' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:235: error: syntax error before "NET"
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:241: error: conflicting types for 'last_errno'
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:118: error: previous declaration of 'last_errno' was here
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:244: error: conflicting types for 'last_error'
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql_com.h:121: error: previous declaration of 'last_error' was here
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:245: error: syntax error before '}' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:269: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:270: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:271: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:272: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:274: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:275: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:276: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:278: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:279: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:280: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:281: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:282: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:283: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:284: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:285: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:287: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:287: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:288: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:291: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:293: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:293: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:300: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:301: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:302: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:303: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:305: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:306: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:309: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:311: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:314: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:316: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:323: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:324: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:326: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:329: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:330: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:332: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:337: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:340: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:344: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:349: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:350: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:351: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:353: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:354: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:355: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:356: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:359: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:360: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:361: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:361: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:362: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:362: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:363: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:363: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:365: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:365: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:366: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:366: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:367: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:367: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:368: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:370: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:371: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:373: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:375: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:377: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:378: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:379: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:382: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:386: error: syntax error before '*' token
 
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:395: error: syntax error before ')' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:396: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:398: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:398: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:399: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:399: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:404: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:405: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:407: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:426: error: syntax error before '*' token
C:/logiciel/devcpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/mysql/mysql.h:428: error: syntax error before '*' token
C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c: In function `main':
C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:10: error: syntax error before "mysql"
C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:11: error: `result' undeclared (first use in this function)
C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:11: error: (Each undeclared identifier is reported only once
C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:11: error: for each function it appears in.)
C:\Documents and Settings\fabien\Mes documents\source c\mysql_test.c:14: error: `mysql' undeclared (first use in this function)
 
Execution terminated


 
C'est du a quoi ?  :??:
 


---------------
Découvre le HFRcoin ✈ - smilies
n°1011473
Erendis
Posté le 13-03-2005 à 20:10:56  profilanswer
 

Sans qu'on voit ton code ça risque d'être dur de te dire.
Verifie 1. Que tu as bien mis (dans le meme ordre).
 
#include <windows.h>  
#include <MySQL\mysql.h>
 
2. Que tu as bien ajouté la librairie libmysql.a à ton projet.
 
Sinon à vu de nez je dirais que y'as soit un problème avec les include, soit une vieille erreur de syntaxe.
 

n°1011479
fabien
Vive la super 5 !
Posté le 13-03-2005 à 20:21:09  profilanswer
 

le code:
 
 

Code :
  1. #include <stdio.h>
  2. #include <mysql/mysql.h>
  3. #define MYSQL_HOST "localhost"
  4. #define MYSQL_DB "db"
  5. #define MYSQL_LOGIN "login"
  6. #define MYSQL_PASSWD "pass"
  7. int main() {
  8.         MYSQL mysql;
  9.         MYSQL_RES *result;
  10.         MYSQL_ROW row;
  11.         mysql_init(&mysql);
  12.         if (!mysql_connect(&mysql,MYSQL_HOST,MYSQL_LOGIN,MYSQL_PASSWD)) {
  13.                 return -1;
  14.         }
  15.         if (mysql_select_db(&mysql,MYSQL_DB)) {
  16.                 mysql_close(&mysql);
  17.                 return -1;
  18.         }
  19.         mysql_query(&mysql,"SELECT champ1 FROM table1" );
  20.         result = mysql_use_result(&mysql);
  21.         while((row = mysql_fetch_row(result))) {
  22.                 printf("%s",row[1]);
  23.                 fflush(stdout);
  24.         }
  25.         mysql_close(&mysql);
  26.         return 0;
  27. }


 
sinon, comment on fait pour ajouter la librairie libmysql.a à mon projet ?


---------------
Découvre le HFRcoin ✈ - smilies
n°1011484
chrisbk
-
Posté le 13-03-2005 à 20:32:56  profilanswer
 

au link (-lmysql), mais la c pas le pb

n°1011499
fabien
Vive la super 5 !
Posté le 13-03-2005 à 20:56:27  profilanswer
 

chrisbk a écrit :

au link (-lmysql), mais la c pas le pb


tu vois pas d'ou viens le probleme ?


---------------
Découvre le HFRcoin ✈ - smilies
n°1011503
chrisbk
-
Posté le 13-03-2005 à 21:00:30  profilanswer
 

non. Perso en debut de fichier j'avais :
 
#include <my_global.h>
#include <mysql.h>
 
et ca marchait comme ca.
 
(si ca marche pas essaye avec mysql/ devant comme tu le fais)


Message édité par chrisbk le 13-03-2005 à 21:00:57
n°1011528
Erendis
Posté le 13-03-2005 à 21:10:43  profilanswer
 

non avec devcpp c'est pas my_global.h il y'aura des conflits de types.
include <windows.h> devant le include <mysql.h> et je pense que ça passe.
Et ptet verifier que le path vers le repertoire de mysql.h est bien inclus.
 
Edit: ah et au passage mysql_connect() ça existe plus c'est mysql_real_connect()
 
Bon le plus simple, c'est un truc qui marche, ça c'est le minimum pour se connecter. Tu devrais pouvoir te debrouiller avec.

Code :
  1. #include <windows.h> //attention à bien le mettre au dessus de Mysql.h
  2. #include <MySQL\mysql.h>
  3. #include <stdio.h>
  4. MYSQL *dataBase ;     //poignée de connexion (le nom de la bd)
  5. MYSQL *erreur ;       //pour recuperer les erreurs  
  6. int connexion_Mysql() ;
  7. int main(int argc, char *argv[]) {
  8.     if( connexion_Mysql() == -1) {
  9.         printf("> [Error]Fonction de connexion à echoue\n" );
  10.     }
  11.     dataBase = NULL;
  12.     mysql_close(dataBase);
  13.     system("PAUSE" );
  14.     return EXIT_SUCCESS;
  15. }
  16. int connexion_Mysql() {
  17.      //Variables concernant les informations sur la base de donnée   
  18.     const char *host ;      //nom de l'hote
  19.     const char *user ;       //login
  20.     const char *passwd ;     //mot de passe  
  21.     const char *bdName ;      //base de donnée
  22.     unsigned int port ;             //port de connexion sur le serveur  
  23.     const char *unix_socket;   //socket
  24.     unsigned long client_flag ; //bof
  25.     MYSQL_RES *myResul = NULL;  //Variable pour recevoir les resultats de la requete
  26.     MYSQL_ROW myRow    = NULL;  //Tableaux des resultats
  27.     //Initialisation des variables  
  28.     host = "localhost" ;  //localhost
  29. user = "root" ;   //login
  30. passwd = "lemotdepasse" ;  //le motdepasse  
  31.     bdName = "nombase" ; //nom de la bd
  32.     port = 3306 ;       //port par defaut
  33.     unix_socket = NULL ; //indique à mysql de se demerder tt seul
  34.     //Initialisation de la connexion
  35.     if( (dataBase = mysql_init(NULL)) == NULL) {
  36.      printf("> [Error]Memoire insuffisante pour allouer une connexion mysql\n" );
  37.  exit(-1) ;
  38. }
  39. printf("Initialisation reussie de Mysql\n" );
  40.     //Connexion sur le serveur  
  41.     if( (erreur = mysql_real_connect(dataBase, host, user, passwd, bdName, port, unix_socket, client_flag) ) == NULL) {
  42.         printf("> [Error]Connexion sur le serveur a echouee! \n" );
  43.  printf("cause: %s\n", mysql_error(dataBase) ) ;
  44.         system("PAUSE" );
  45.  exit(-1) ;
  46. }
  47.     printf("Connexion reussie au serveur Mysql\n" ); 
  48.    
  49.    
  50.     if(mysql_select_db(dataBase, bdName) < 0){
  51.         printf("> [Error]Lors de la selection de la base de donnee\n" );
  52.        
  53.         //Deconnexion du serveur mysql
  54.         mysql_close(dataBase);
  55.         exit(-1) ;
  56.     }
  57.     printf("Selection de la base de donnee reussie\n" ); 
  58.    
  59. }


Message édité par Erendis le 13-03-2005 à 21:18:04
n°1011541
fabien
Vive la super 5 !
Posté le 13-03-2005 à 21:18:12  profilanswer
 

donc c'est pour ca que j'ai ces erreur maintenant ? [:dawa]
 

C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x51):mysql_test2.c: undefined reference to `mysql_connect'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x75):mysql_test2.c: undefined reference to `mysql_select_db@8'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x9c):mysql_test2.c: undefined reference to `mysql_query@8'
 
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0xbb):mysql_test2.c: undefined reference to `mysql_store_result@4'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0xe5):mysql_test2.c: undefined reference to `mysql_fetch_row@4'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x10a):mysql_test2.c: undefined reference to `mysql_num_fields@4'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x156):mysql_test2.c: undefined reference to `mysql_eof@4'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x176):mysql_test2.c: undefined reference to `mysql_free_result@4'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x185):mysql_test2.c: undefined reference to `mysql_close@4'
C:\DOCUME~1\fabien\LOCALS~1\Temp/ccMfbaaa.o(.text+0x1ad):mysql_test2.c: undefined reference to `mysql_error@4'


---------------
Découvre le HFRcoin ✈ - smilies
n°1011544
Erendis
Posté le 13-03-2005 à 21:20:06  profilanswer
 

Là il manque la librairie c'est clair.

n°1011547
fabien
Vive la super 5 !
Posté le 13-03-2005 à 21:21:38  profilanswer
 

Erendis a écrit :

Là il manque la librairie c'est clair.


pourtant dans le dossier lib de dev cpp, j'ai libmySQL.a
 
ya quelque chose a faire ?


---------------
Découvre le HFRcoin ✈ - smilies
n°1011549
Erendis
Posté le 13-03-2005 à 21:26:00  profilanswer
 

Et tu as bien #include <MySQL\mysql.h> et pas #include <mysql.h> ?
 
Et la librairie suffit pas de l'avoir, faut l'ajouter au projet comme j'ai expliqué au dessus


Message édité par Erendis le 13-03-2005 à 21:26:42
n°1011554
fabien
Vive la super 5 !
Posté le 13-03-2005 à 21:32:43  profilanswer
 

Erendis a écrit :

Et tu as bien #include <MySQL\mysql.h> et pas #include <mysql.h> ?
 
Et la librairie suffit pas de l'avoir, faut l'ajouter au projet comme j'ai expliqué au dessus


 
pour le chemin de mysql.h c'est le bon
Sinon, je ne sais pas comment on fait pour ajouter une librairie au projet. On fait comment ?


---------------
Découvre le HFRcoin ✈ - smilies
n°1011562
Erendis
Posté le 13-03-2005 à 21:46:04  profilanswer
 

Ah pardon je croyais l'avoir mis alors tu vas dans  
Projet->options du projet->onglet paramètres->Editeur de lien->ajouter fichier-> %\Dev-cpp\lib\libmySQL.a  
 

n°1011565
fabien
Vive la super 5 !
Posté le 13-03-2005 à 21:49:37  profilanswer
 

Erendis a écrit :

Ah pardon je croyais l'avoir mis alors tu vas dans  
Projet->options du projet->onglet paramètres->Editeur de lien->ajouter fichier-> %\Dev-cpp\lib\libmySQL.a


a mais j'ai pas fait de projet, j'ai juste un fichier source [:gratgrat]
bon ben je vais essayer avec un projet.


---------------
Découvre le HFRcoin ✈ - smilies
n°1011569
fabien
Vive la super 5 !
Posté le 13-03-2005 à 21:56:35  profilanswer
 

meme en rajoutant la librairie, j'ai les memes erreurs:
 
 

Compiler: Default compiler
Building Makefile: "C:\logiciel\devcpp\lib\Makefile.win"
Executing  make...
make.exe -f "C:\logiciel\devcpp\lib\Makefile.win" all
gcc.exe -c "../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.c" -o "../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o" -I"include"    
 
gcc.exe "../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o"  -o "mysql_test3.exe" -L"lib"  
 
../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o(.text+0x53):mysql_test3.c: undefined reference to `mysql_close@4'
../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o(.text+0xb3):mysql_test3.c: undefined reference to `mysql_init@4'
../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o(.text+0x126):mysql_test3.c: undefined reference to `mysql_real_connect@32'
../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o(.text+0x150):mysql_test3.c: undefined reference to `mysql_error@4'
../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o(.text+0x19b):mysql_test3.c: undefined reference to `mysql_select_db@8'
../../../Documents and Settings/fabien/Mes documents/source c/mysql_test3.o(.text+0x1bb):mysql_test3.c: undefined reference to `mysql_close@4'
collect2: ld returned 1 exit status
 
make.exe: *** [mysql_test3.exe] Error 1
 
Execution terminated


---------------
Découvre le HFRcoin ✈ - smilies
n°1011577
Erendis
Posté le 13-03-2005 à 22:01:45  profilanswer
 

Telecharge ça -Lien retiré- et lance le fichier .dev, dit moi si ça passe.


Message édité par Erendis le 06-05-2005 à 16:32:44
n°1011584
fabien
Vive la super 5 !
Posté le 13-03-2005 à 22:14:33  profilanswer
 

Erendis a écrit :

Telecharge ça http://famille.fourny.free.fr/Artiste/test.zip et lance le fichier .dev, dit moi si ça passe.


oué ca passe, en fait j'ai mal ajouté la librairie :D
j'avais fait projet / add to projet  :whistle:  


---------------
Découvre le HFRcoin ✈ - smilies
n°1011586
Erendis
Posté le 13-03-2005 à 22:20:33  profilanswer
 

Bon bah voilà pb résolu :)
 
Edit le titre du topic en résolu, ça evitera au gens de le lire pour rien. Ou de savoir que y'as la solution :)

n°1011591
fabien
Vive la super 5 !
Posté le 13-03-2005 à 22:31:26  profilanswer
 

quand je veux executer le programme, ca me dit que libmysql.dll n'existe pas :??:
 
ya pas moyen d'integrer la librairie au .exe ?


---------------
Découvre le HFRcoin ✈ - smilies
n°1011594
Erendis
Posté le 13-03-2005 à 22:39:40  profilanswer
 

ptet mais je sais pas comment on fait, moi je copie le .dll (tu prend celui qui est dans ton repertoire mysql %/mysql/MySQL Server 4.1\lib\opt\) dans le repertoire de ton projet c'est le plus simple et en général c'est comme ça que tout le monde fait.

n°1011607
fabien
Vive la super 5 !
Posté le 13-03-2005 à 22:53:15  profilanswer
 

ok merci pour ton aide :jap:
 
sinon, ou c'est qu'on peut avoir la liste des fonction pour mysql ?
 
car je suis habitué au fonctions en php, mais je connais pas celle de c.


Message édité par fabien le 13-03-2005 à 22:54:02

---------------
Découvre le HFRcoin ✈ - smilies
n°1011621
Erendis
Posté le 13-03-2005 à 23:08:48  profilanswer
 

http://dev.mysql.com/doc/mysql/fr/mysql-apis.html
 
De façon générale la doc sur le site de mysql est plutôt pas mal.  
 
Après faut juste te trouver un tutorial sur comment recuperer les resultats de tes requetes et c'est bon.  
 
Comme fonctions importantes y'as mysql_query pour faire des requêtes, mysql_use_result et mysql_fetch_row pour recupérer les resultats. Tu dois pouvoir t'en sortir avec la doc du site normalement.

n°1011623
fabien
Vive la super 5 !
Posté le 13-03-2005 à 23:14:16  profilanswer
 

encore une fois, merci pour ton aide :jap:
 


---------------
Découvre le HFRcoin ✈ - smilies
n°1017070
AGA
La boîte à Bokeh!
Posté le 18-03-2005 à 11:10:12  profilanswer
 

Erendis a écrit :

non avec devcpp c'est pas my_global.h il y'aura des conflits de types.
include <windows.h> devant le include <mysql.h> et je pense que ça passe.
Et ptet verifier que le path vers le repertoire de mysql.h est bien inclus.
 
Edit: ah et au passage mysql_connect() ça existe plus c'est mysql_real_connect()
 
Bon le plus simple, c'est un truc qui marche, ça c'est le minimum pour se connecter. Tu devrais pouvoir te debrouiller avec.

Code :
  1. #include <windows.h> //attention à bien le mettre au dessus de Mysql.h
  2. #include <MySQL\mysql.h>
  3. #include <stdio.h>
  4. MYSQL *dataBase ;     //poignée de connexion (le nom de la bd)
  5. MYSQL *erreur ;       //pour recuperer les erreurs  
  6. int connexion_Mysql() ;
  7. int main(int argc, char *argv[]) {
  8.     if( connexion_Mysql() == -1) {
  9.         printf("> [Error]Fonction de connexion à echoue\n" );
  10.     }
  11.     dataBase = NULL;
  12.     mysql_close(dataBase);
  13.     system("PAUSE" );
  14.     return EXIT_SUCCESS;
  15. }
  16. int connexion_Mysql() {
  17.      //Variables concernant les informations sur la base de donnée   
  18.     const char *host ;      //nom de l'hote
  19.     const char *user ;       //login
  20.     const char *passwd ;     //mot de passe  
  21.     const char *bdName ;      //base de donnée
  22.     unsigned int port ;             //port de connexion sur le serveur  
  23.     const char *unix_socket;   //socket
  24.     unsigned long client_flag ; //bof
  25.     MYSQL_RES *myResul = NULL;  //Variable pour recevoir les resultats de la requete
  26.     MYSQL_ROW myRow    = NULL;  //Tableaux des resultats
  27.     //Initialisation des variables  
  28.     host = "localhost" ;  //localhost
  29. user = "root" ;   //login
  30. passwd = "lemotdepasse" ;  //le motdepasse  
  31.     bdName = "nombase" ; //nom de la bd
  32.     port = 3306 ;       //port par defaut
  33.     unix_socket = NULL ; //indique à mysql de se demerder tt seul
  34.     //Initialisation de la connexion
  35.     if( (dataBase = mysql_init(NULL)) == NULL) {
  36.      printf("> [Error]Memoire insuffisante pour allouer une connexion mysql\n" );
  37.  exit(-1) ;
  38. }
  39. printf("Initialisation reussie de Mysql\n" );
  40.     //Connexion sur le serveur  
  41.     if( (erreur = mysql_real_connect(dataBase, host, user, passwd, bdName, port, unix_socket, client_flag) ) == NULL) {
  42.         printf("> [Error]Connexion sur le serveur a echouee! \n" );
  43.  printf("cause: %s\n", mysql_error(dataBase) ) ;
  44.         system("PAUSE" );
  45.  exit(-1) ;
  46. }
  47.     printf("Connexion reussie au serveur Mysql\n" ); 
  48.    
  49.    
  50.     if(mysql_select_db(dataBase, bdName) < 0){
  51.         printf("> [Error]Lors de la selection de la base de donnee\n" );
  52.        
  53.         //Deconnexion du serveur mysql
  54.         mysql_close(dataBase);
  55.         exit(-1) ;
  56.     }
  57.     printf("Selection de la base de donnee reussie\n" ); 
  58.    
  59. }



Salut,
 
Avec ton code
j'obtiens ça :  
[c]
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
stastrict.cpp:
Warning W8057 stastrict.cpp 22: Parameter 'argc' is never used in function main(
int,char * *)
Warning W8057 stastrict.cpp 22: Parameter 'argv' is never used in function main(
int,char * *)
Warning W8070 stastrict.cpp 72: Function should return a value in function conne
xion_Mysql()
Warning W8004 stastrict.cpp 72: 'myRow' is assigned a value that is never used i
n function connexion_Mysql()
Warning W8004 stastrict.cpp 72: 'myResul' is assigned a value that is never used
 in function connexion_Mysql()
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'mysql_init' referenced from C:\STASTRICT\STASTRICT.O
BJ
Error: Unresolved external 'mysql_real_connect' referenced from C:\STASTRICT\STA
STRICT.OBJ
Error: Unresolved external 'mysql_error' referenced from C:\STASTRICT\STASTRICT.
OBJ
Error: Unresolved external 'mysql_select_db' referenced from C:\STASTRICT\STASTR
ICT.OBJ
Error: Unresolved external 'mysql_close' referenced from C:\STASTRICT\STASTRICT.
OBJ[/c]
 
J'ai BCC5.5, le freeware et je veux faire une appli en ligne de commande.
 
Une idée?

n°1017340
AGA
La boîte à Bokeh!
Posté le 18-03-2005 à 14:03:32  profilanswer
 

Personne pour me guider? :/

mood
Publicité
Posté le   profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C

  c + mysql

 

Sujets relatifs
Quel livre PHP/MySQL pour débuter ?[MySql] Petit soucis de requête
MySql - Procédures stockées et triggers[MySQL 4.0.15] SELECT imbriqués : erreur
Question PHP - mysqlConversion d'une base Access en uune base MySQL.
Problème MySQL, accès localhost suppriméMySQL requête ciblée sur une chaine de caractère
Déménager une grosse base de données mySQLPilotes ODBC MySQL incompatible avec mon système ?
Plus de sujets relatifs à : c + mysql


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR