int iCount=m_Recordset->Fields->GetCount();
while (!m_Recordset->adoEOF ) 
{
CString strToFile,value;
if(sFilePrefix.Compare("ProFlow")==0 || sFilePrefix.Compare("Proroute")==0)
strToFile=",";
for(int i=0;i<iCount;i++)
{
VARIANT vt;
Field * pf = m_Recordset->GetFields()->GetItem((long)i);  //这里程序会异常
pf->get_Value(&vt);
if(vt.vt==VT_NULL)
value = "";
else
value=((BSTR)_bstr_t(vt));
value.TrimLeft();
value.TrimRight();
strToFile += value;
strToFile += ",";
}
fprintf(fp, strToFile.GetBuffer());
fprintf(fp, "\n"); //取下一条记录
m_Recordset->MoveNext();
}