执行插入insert。返回该插入产生的自增ID
CStringA db_name="XXX"; CStringA db_address = "X.X.X.X"; CStringA db_user = "UUU"; CStringA db_psd = "PPPP"; unsigned int db_port = 1234; MYSQL mysql; if (mysql_init(&mysql) != NULL) { mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "gb2312"); INT nTimeout = 3; //秒 mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, &nTimeout); if (mysql_real_connect(&mysql, db_address, db_user, db_psd, db_name, db_port, NULL, 0)) { CStringA sql = ""; sql.Format("INSERT into tttt(time) values(now())"); int id = -123; int ret = mysql_query(&mysql, sql); if (ret == 0) { id = mysql_insert_id(&mysql); } } mysql_close(&mysql); }
原创文章,作者:,如若转载,请注明出处:https://blog.ytso.com/274655.html