[Quote=引用 11 楼 liuxingyu0502 的回复:]
我想知道怎么获取row_count的值,我用mysql_real_query都不能正常获取他的结果
[/Quote]
使用mysql_affected_rows()来获取
//测试代码
strcpy_s(query,100,"update test2 set test=88 where test = 65");
result= mysql_query(conn_ptr,query);
if (result == 0)
printf ("Row affected number are %d\n",mysql_affected_rows(conn_ptr));
mysql_close(conn_ptr);
ROW_COUNT() returns the number of rows updated, inserted, or deleted by the preceding statement. This is the same as the row count that the mysql client displays and the value from the mysql_affected_rows() C API function.
mysql> INSERT INTO t VALUES(1),(2),(3);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)
mysql> DELETE FROM t WHERE i IN(1,2);
Query OK, 2 rows affected (0.00 sec)
mysql> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)