读书人

两个记录集对象的使用,该怎么解决

发布时间: 2012-02-29 16:44:11 作者: rapoo

两个记录集对象的使用
CoInitialize(NULL); //访问comm库
_ConnectionPtr pConn(__uuidof(Connection));//定义对象的同时进行初始化

_RecordsetPtr pRst(__uuidof(Recordset));
_RecordsetPtr pRst1(__uuidof(Recordset));
pConn->ConnectionString = "Provider=SQLOLEDB.1;Password=123456;Data Source=王莲花;User ID=sk_medical;Initial Catalog=Infusion_Station";
pConn->Open("","","",adConnectUnspecified);

CString str_person_drug_info;
str_person_drug_info.Format(L"select *from patient_drug_info where is_cur = '%s'",L"1");

pRst = pConn->Execute((_bstr_t)str_person_drug_info , NULL , adCmdText);
int flag_drug = 0;//判断此位置有无关联药品
if(!pRst->rsEOF)
{
if(m_is_cur == L"1")
{
//查询病历号
for(int i = 0;i<11;i++)
{
barcode = pRst->GetCollect("barcode_const[i]");
pump_type = pRst->GetCollect("relate_pump_type_const[i]");
pump_id = pRst->GetCollect("relate_pump_const[i]");
if((pump_type==m_PumpType )&&(pump_id==m_PumpID))
{
/////查询条码对应药品信息
////////////////////查询药物信息
{
CString str_drug_list;
CString drugname;
str_drug_list.Format(L"select *from drug_list where barcode ='%s'",barcode);
pRst1 = pConn->Execute((_bstr_t)str_drug_list , NULL , adCmdText);
if(!pRst1->rsEOF)
{
drugname = pRst->GetCollect("drug_name");
m_Static_DrugName.SetWindowTextW(drugname);
flag_drug = 1;
}
}
}
}
}

}
if(flag_drug ==0)
{
m_Static_DrugName.SetWindowTextW(L"暂无药品");
}
pRst1->Close();
pRst1.Release();
pRst->Close();
pRst.Release();
pConn->Close();
pConn.Release();
CoUninitialize();

大家能帮我看看吗?我这样使用两个记录集对象会出错

[解决办法]
GetCollect("barcode_const[i]");
//如果要用索引就不要字段名,如果要字段名就不要索引,再说,你的索引是写在string里面的,其实是没用的.

[解决办法]

探讨
GetCollect("barcode_const[i]");
//如果要用索引就不要字段名,如果要字段名就不要索引,再说,你的索引是写在string里面的,其实是没用的.

读书人网 >VC/MFC

热点推荐