求助 freetds 多线程问题?
代码太多,这里是关键代码,大家有疑问的地方可以让我贴出。
void thread_WaitRecv(){ char* sql; sql = malloc(sizeof(char)*50); memset(sql,0,sizeof(char)*50); sprintf(sql,"select count(*) from UpdateTable"); //查询数据库 dbcmd(dbprocess, sql); if(dbsqlexec(dbprocess) == FAIL) //执行后这里报错:[Inferior 1 (process 3108) exited with code 01],不知道这是什么情况?求助!!! { LOG("MS SQL:%s", "Query table 'isUpdateTable' error."); } DBINT result_code; char temCount[20]={0}; while ((result_code = dbresults(dbprocess)) != NO_MORE_RESULTS){ if (result_code == SUCCEED){ //设置缓冲区 dbbind(dbprocess, 1, CHARBIND, (DBINT)0, (BYTE*)temCount); while (dbnextrow(dbprocess) != NO_MORE_ROWS){ memcpy(count,temCount,20); memset(temCount,0,20); } } } }int main(void){ initmssql(); sleep(3);//开启线程检测表是否更新 pthread_t thread; int temp; memset(&thread,0,sizeof(thread)); /*创建线程*/ temp=pthread_create(&thread,NULL,(void *(*)(void *))thread_WaitRecv,NULL); LOG("pthread:%s", "线程穿件成功!");}