1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| #include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <connection.h>
#include <query.h>
#include <coldata.h>
#include <result.h>
#include <row.h>
//#include <sqlplus.hh>
#include <strings.h>
#include <mysql++.h>
#include <string_util.h>
#define HOST "localhost"
#define DB "atelier"
#define USERNAME "root"
#define PASSWORD ""
using namespace std;
int main(int argc, char *argv[])
{
struct machine{
int reference;
string type;
};
struct outil{
int reference;
string localisaation;
string compatibilite;
int localisationmachine;
};
struct operateur{
int reference;
string nom;
string etat;
int machine;
};
while (true)
{
int choix;
printf("Tapez 1 pour ajouter une machine\n");
scanf("%d",&choix);
if (choix==1) {
machine machine;
cout << "Entrer nom machine\n";
cin >> machine.type;
cout << "Entrer numero\n";
cin >> machine.reference;
mysqlpp::Connection connection(true);//atelier, localhost, root, "",0,60,0,0);
try{
connection.connect("", HOST, USERNAME, PASSWORD);
connection.select_db (DB);
mysqlpp::Query query = connection.query();
query << "INSERT INTO machine " << "(reference,type) VALUES (\"\",\""<< machine.type << "\")";
mysqlpp::Result res = query.store();
}
catch( mysqlpp::BadQuery er){
}
/*
try {
query.execute();
} catch( mysqlpp::BadQuery er) {
cerr << "Error: " << er.<< endl;
return -1;
}
}/* catch (BadQuery er) {
cerr << "Error: " << er.error << endl;
return -1;
}*/
};
return 0;
}
} |
Partager