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

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

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
m_IsConnectionOpen=false; m_pConnection-Close(); m_pConnection=NULL; m_pRecordset=NULL; } } n 最后添加按钮的消息响应函数如下 void CZjyDlg::OnButton1() { // TODO: Add your control notifi

                    m_IsConnectionOpen=false;

                    m_pConnection->Close();

                   

                    m_pConnection=NULL;

                    m_pRecordset=NULL;

         }

}

n          最后添加按钮的消息响应函数如下

void CZjyDlg::OnButton1()

{

         // TODO: Add your control notification handler code here

         VARIANT_BOOL valEof;        

         HRESULT hr;        

         CString strColName;BSTR bstrColName;

         CString strValue;VARIANT varValue;

         long  ColCount,i; int RowCount=0;

         Fields * fields=NULL;Field * field=NULL;

         VARIANT varCounter;

         varCounter.vt=VT_I4;

         varCounter.lVal=0;

         try

         {

                   m_list.DeleteAllItems();

                   while(m_list.DeleteColumn(0));

                   hr=m_pRecordset->get_Fields(&fields);

                   if(SUCCEEDED(hr)) hr=fields->get_Count(&ColCount);

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

                   {       

                            hr=fields->Item[i]->get_Name(&bstrColName);

                            strColName=bstrColName;

                            int nWidth=m_list.GetStringWidth(strColName)+15;

                            m_list.InsertColumn(i,strColName,LVCFMT_LEFT,nWidth);

                   }

精彩图集

赞助商链接