龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC下的ADO编程入门(2-4)(4)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
if(SUCCEEDED(hr)) fields-Release(); m_pRecordset-get_adoEOF(valEof); while(true) { if(valEof)break; m_pRecordset-Fields-get_Item(varCounter,field); field-get_Value(varValue); strValue=VariantToString(

                   if(SUCCEEDED(hr)) fields->Release();

                   m_pRecordset->get_adoEOF(&valEof);

                   while(true)

                   {

                            if(valEof)break;

                            m_pRecordset->Fields->get_Item(varCounter,&field);

                            field->get_Value(&varValue);

                            strValue=VariantToString(varValue);

                            m_list.InsertItem(RowCount,strValue);

                            for(i=1;i<ColCount;i++)

                            {

                                     varCounter.lVal =i;

                                     m_pRecordset->Fields->get_Item(varCounter,&field);

                                     field->get_Value(&varValue);

                                     strValue=VariantToString(varValue);

                                     m_list.SetItemText(RowCount,i,(LPCTSTR)strValue);

                            }

                            RowCount++;

                            m_pRecordset->MoveNext();

                            m_pRecordset->get_adoEOF(&valEof);

                            varCounter.lVal=0;

                   }

                   m_pRecordset->Close();

         }

         catch(_com_error &e)

         {

                   _bstr_t bstrSource(e.Source());

                   _bstr_t bstrDescription(e.Description());

                   TRACE(" Code=%08lx ", e.Error);

                   TRACE(" Code meaning = %s ", e.ErrorMessage);

                   TRACE(" Source = %s ", (LPCTSTR)bstrSource);

                   TRACE(" Description = %s ", (LPCTSTR)bstrDescription);

         }

         catch(...)

         {

 

精彩图集

赞助商链接