ifstream in("data.txt");
if (!in)
{
cout << "bad data.txt" << endl;
return 0;
}
string index,greetings,intro1,intro2,intro3,intro4,intro5,intro6;
while(in >> index >> greetings >> intro1 >> intro2 >> intro3 >> intro4 >> intro5 >> intro6)
{
WriteLog("data.log","%d:%s:%s:%s:%s:%s:%s:%s",atoi(index.c_str()),greetings.c_str(),intro1.c_str(),intro2.c_str(),intro3.c_str(),intro4.c_str(),
intro5.c_str(),intro6.c_str());
char sql[1024] ={0};
char temp[2048] = {0};
sprintf(sql,"insert into tb_mmsbody values (%u,\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",
atoi(index.c_str()),greetings.c_str(),intro1.c_str(),intro2.c_str(),intro3.c_str(),intro4.c_str(),
intro5.c_str(),intro6.c_str());
G2U(temp,2048,sql,strlen(sql));
WriteLog("data.log","%s",temp);
int ret = mysql_real_query(conn_ptr, temp, static_cast<int>(strlen(temp)));
if(ret != 0)
{
cout<<"query error"<<endl;
cout << mysql_error(conn_ptr) << endl;
}
}