c++ - DB (MYSQL) command to query in c ++ -


sprintf_s(query, "update point set p%d=%d hakbun='%d';", no, point, hakbun); 

the data in database not output reason of sentence.

what problem?

void updatepoint(mysql *con) {      mysql * connection = null, conn;     mysql_res * sql_result;     mysql_row sql_row;      int hakbun, field, j, query_stat, no, point;     char query[1024];      cout << "student id > ";     cin >> hakbun;      cout << "            ┌────────────────────────────┐" << endl;     cout << "            └────────────────────────────┘" << endl;     cout << "              num > ";     cin >> no;     cout << "                              point > ";     cin >> point;      sprintf_s(query, "update point set p%d='%d' hakbun='%d';", no, point, hakbun);     sprintf_s(query, "select * point hakbun = '%d';", hakbun);     cout << sizeof(query) << endl;     query_stat = mysql_query(connection, query);     sql_result = mysql_store_result(connection);     while ((sql_row = mysql_fetch_row(sql_result)) != null) {         void table();         printf("  %s\t %s  %s   %s  %s  %s\t%s\t%s\t %s\t%s\t%s\n", sql_row[0], sql_row[1], sql_row[2], sql_row[3], sql_row[4], sql_row[5], sql_row[6], sql_row[7], sql_row[8], sql_row[9], sql_row[10]);     }     mysql_free_result(sql_result); } 

you need execute update query before reassign query select query.

you're missing second argument sprintf_s(), should contain size of query buffer. , when call table(), shouldn't put void before -- makes function declaration, not function call.

you're using variable connection in mysql_query() calls, never assigned mysql connection. function takes connection parameter in con, should use instead.

sprintf_s(query, sizeof(query), "update point set p%d='%d' hakbun='%d';", no, point, hakbun); mysql_query(con, query); sprintf_s(query, sizeof(query), "select * point hakbun = '%d';", hakbun); mysql_query(con, query); sql_result = mysql_store_result(con); while ((sql_row = mysql_fetch_row(sql_result)) != null) {     table();     printf("  %s\t %s  %s   %s  %s  %s\t%s\t%s\t %s\t%s\t%s\n", sql_row[0], sql_row[1], sql_row[2], sql_row[3], sql_row[4], sql_row[5], sql_row[6], sql_row[7], sql_row[8], sql_row[9], sql_row[10]); } mysql_free_result(sql_result); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -