数据表biaohao,第一列dianbiaohao,第二列password
listctrl变量m_meterList,第一列放数据表的第一列内容,第二列放数据表的第二列内容
我的代码如下 CString m_strBH[32],m_strPS[32];
_variant_t vnRCount; //存放第一列
CString strMsg;
_variant_t vmRCount;//存放第二列
CString strMsh;////
CString strSQL;////放SQL语句
strSQL.Format("select * from biaohao");
m_pRecordset=m_pConnection->Execute(_bstr_t(strSQL),NULL,adCmdText);
////////////执行该语句,将值放进记录集里
int i=0,j=0;//共几项
//数据存放
while(!m_pRecordset->adoEOF)
{
vnRCount = m_pRecordset->GetCollect("dianbiaohao");
strMsg=(char*)_bstr_t(vnRCount);
vmRCount=m_pRecordset->GetCollect("password");////将选中的数据标识功能取出来
strMsh=(char*)_bstr_t(vmRCount);
m_strBH[i]=strMsh;
m_strPS[i]=strMsg; m_meterList.SetItemText (i,0,m_strBH[i]);//第一列
m_meterList.SetItemText (i,1,m_strPS[i]);//第二列 m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
return;
编译无错误,只是运行后不能将数据显示在m_meterList上,请问该怎么改呢?谢谢
listctrl变量m_meterList,第一列放数据表的第一列内容,第二列放数据表的第二列内容
我的代码如下 CString m_strBH[32],m_strPS[32];
_variant_t vnRCount; //存放第一列
CString strMsg;
_variant_t vmRCount;//存放第二列
CString strMsh;////
CString strSQL;////放SQL语句
strSQL.Format("select * from biaohao");
m_pRecordset=m_pConnection->Execute(_bstr_t(strSQL),NULL,adCmdText);
////////////执行该语句,将值放进记录集里
int i=0,j=0;//共几项
//数据存放
while(!m_pRecordset->adoEOF)
{
vnRCount = m_pRecordset->GetCollect("dianbiaohao");
strMsg=(char*)_bstr_t(vnRCount);
vmRCount=m_pRecordset->GetCollect("password");////将选中的数据标识功能取出来
strMsh=(char*)_bstr_t(vmRCount);
m_strBH[i]=strMsh;
m_strPS[i]=strMsg; m_meterList.SetItemText (i,0,m_strBH[i]);//第一列
m_meterList.SetItemText (i,1,m_strPS[i]);//第二列 m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
return;
编译无错误,只是运行后不能将数据显示在m_meterList上,请问该怎么改呢?谢谢
m_meterList.SetItemText(i,1,m_strPS[i]);//第二列改成:m_meterList.InsertItem(i,m_strBH[i]);//第一列
m_meterList.SetItemText(i,1,m_strPS[i]);//第二列
改成 m_meterList.InsertItem(i,m_strPS[i]);//第一列 ]
m_meterList.SetItemText(i,1,m_strBH[i]);//第二列
就好了