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
|
#include "stdafx.h"
//#include <stdlib.h>
#include <iostream>
//#include <stdio.h>
//#include <stdarg.h>
#include <windows.h>
#include <mysql.h>
//#include <cstdio>
//#include <cstdlib>
MYSQL *mysql;
MYSQL_RES *results;
MYSQL_ROW record;
static char *server_options[] = { "mysql-test", "--datadir=C:\\BANKS\\data",
"--language=C:\\Server\\MySQL\\share\\english", NULL};
int num_elements = sizeof(server_options)/ sizeof(char *) - 1;
static char *server_groups[] = { "libmysqld_server", NULL };
using namespace std;
int main(int argc, char* argv[])
{ int retval;
retval = mysql_library_init(num_elements, server_options, (char **) server_groups);
mysql = mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);
int con;
mysql_real_connect(mysql, NULL, NULL, NULL, "banks", 0, NULL, 0);
int xsa;
xsa = mysql_query(mysql, "SELECT * FROM banks");
if(xsa == 0){
cout << "OOK" << endl;
results = mysql_store_result(mysql);
while((record = mysql_fetch_row(results))) {
printf("%s – %s \n", record[0], record[1]);
}
}else {
cout << "DOU, THE QUERY FAILED" << endl;
}
mysql_free_result(results);
mysql_close(mysql);
system("PAUSE");
return 0;
}
|