C语言和MYSQL数据库(3)


MYSQL * dbmysql = mysql_init(NULL);

dbmysql = mysql_real_connection(dbmysql,

"localhost",

"root",

"",

"test_second",

0,

NULL,

0);

if(dbmysql==NULL){

printf("连接失败!\n);

}else{

printf("连接成功!\n);

int ret = mysql_query(dbmysql,"update dept set dept_emps = 1");

if(ret ==0){

printf("执行成功!\n);

int cnt = mysql_fetch_row(dbmysql);

printf("影响了%d行”,&cnt);

}else{

printf("执行失败!\n);

}

mysql_close(dbmysql);

}

你可能感兴趣的:(C语言和MYSQL数据库(3))