我的程序是需要定时对数据库操作的.在应用的CMainFrame类的CMainFrame::OnCreate中加入SetTimer(1,1000,null),然后在处理数据库的View类里面添加Message handler,选择WM_TIMER,然后在OnTimer函数中添加对数据库的处理代码。可问题是,怎么运行时发现没有执行对数据库的操作,
void CIconView::OnTimer(UINT nIDEvent) 
{
// TODO: Add your message handler code here and/or call default
FILE *fp;
int j;
char ch;
char getdata[25];
if((fp=fopen("e:\\test.txt","rb+"))==NULL)
{
AfxMessageBox("open test.txt err!");
exit(0);
}
ch=fgetc(fp);
int i=0;
while(ch!=EOF)
{
getdata[i]=ch;
ch=fgetc(fp);
i++;
}
// fread(&coiltemp,sizeof(struct coil),1,fp);
fclose(fp);
for(j=0;j<4;j++)
coiltemp.Form_id[j]=getdata[j];
coiltemp.Form_id[4]='\0';
for(j=0;j<8;j++)
coiltemp.Feedbackdate[j]=getdata[j+4];
coiltemp.Feedbackdate[8]='\0';
for(j=0;j<2;j++)
coiltemp.Rollingtime[j]=getdata[j+13];
coiltemp.Rollingtime[2]='\0';
for(j=0;j<5;j++)
coiltemp.Unitecoilweight[j]=getdata[j+14];
coiltemp.Unitecoilweight[5]='\0';

m_pSet->AddNew();
m_pSet->m_form_id=coiltemp.Form_id;
m_pSet->m_feedback_date=coiltemp.Feedbackdate;
m_pSet->m_rolling_time=atol(coiltemp.Rollingtime);
m_pSet->m_coil_weight=coiltemp.Unitecoilweight;


    m_pSet->Update();
if (!m_pSet->IsBOF())
{
m_pSet->MoveLast();

}
UpdateData(FALSE);         

AfxMessageBox("Insert data OK!");

CRecordView::OnTimer(nIDEvent);
}
麻烦给看看,谢谢!