#include <stdio.h>
#include "/home/mysql/include/mysql.h"
int main()
{
MYSQL mysql
MYSQL_RES *result=NULL
MYSQL_FIELD *field=NULL
mysql_init(&mysql)
mysql_real_connect(&mysql, "localhost", "root", "neusoft", "test", 3306, NULL, 0)
// string sql = "create table a1(col int)"
// mysql_query(&mysql,"insert into a values(3)")
mysql_query(&mysql,"select col from a")
result=mysql_store_result(&mysql)
int fieldcount = mysql_num_fields(result)
MYSQL_ROW row
row = mysql_fetch_row(result)
while(NULL != row)
{
for(int i=0i<fieldcounti++)
{
//field=mysql_fetch_field_direct(result,i)
//printf("%s",row[i])
std::cout<<row[i]<<std::endl
}
//std::cout<<std::endl
row = mysql_fetch_row(result)
}
//mysql_query(&mysql,sql.c_str())
mysql_close(&mysql)
}
这是我成功 *** 作的代码。。。。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)