#include #include #include #include #include using namespace std;
int main( int argc, char * argv[] ) { //connection params
char *host = "localhost"; char *user = "root"; char *pass = "123"; char *db = "test"; MYSQL *mysql; MYSQL_RES *res; MYSQL_FIELD * fd ;
MYSQL_ROW row;
char szSqlText[500]="";
int i;
int tcreate=0;
if ( (mysql = mysql_init((MYSQL*) 0)) //初始化数据结构 &&
mysql_real_connect( mysql, host, user, pass, db, 0, NULL, 0 ) ) { mysql_set_character_set(mysql,"utf8"); //connection character set
//wait for posibility to check system/mysql mysqlets
if(tcreate) { sprintf(szSqlText, //构造SQL语句 "create table mytable" //新建一张表 "(time datetime, s1 char(6), " "s2 char(11), s3 int, s4 int)"); if (mysql_query( mysql, szSqlText)) //执行SQL语句 {//执行SQL语句出错 cout<<"Can't create table:"<

1万+

被折叠的 条评论
为什么被折叠?



