I am using the Mysql C api and the DevPack made for this. But when I am using this code, I always get an Illegal Operation message when running the program:
So I added some couts to see how far the program got, before illegal operation message appears. The last cout displayed is mysql field done. Any ideas?Code:#include <windows.h> #include <iostream> #include <mysql/mysql.h> using namespace std; int main() { char *host = "sql1.badblock.com"; char *user = "theuser"; char *pass = "thepassword"; char *db = "thedb"; MYSQL_RES *result; MYSQL *res; MYSQL *sock; sock = mysql_init(0); if (sock) cout << "sock handle ok!" << endl; else { cout << "sock handle failed!" << endl; return EXIT_FAILURE; } if (res=mysql_real_connect(sock, host, user, pass, db, 0, NULL, 0)) cout << "connection ok!" << endl; else { cout << "connection failed!" << endl; return EXIT_FAILURE; } mysql_query(res,"SELECT address FROM music WHERE pass=euro8"); cout<<"Query done!"; result=mysql_store_result(res); cout<<"Store result done!"; MYSQL_FIELD *field; cout<<"mysql field done!"; while(field = mysql_fetch_field(result)) { cout<<"in while!"; cout<<field; } cout<<"while done!"; cin.get(); mysql_close(sock); return EXIT_SUCCESS; }



LinkBack URL
About LinkBacks


