VC下的ADO编程入门(2-4)(3)
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);
}
- 上一篇:VC快捷键:
- 下一篇:VC下的ADO编程入门(2-3)