RecordsetPtr rsUrun;
rsUrun.CreateInstance(__uuidof(Recordset));
try{
_variant_t Holder;
CString cQry=_T("");
CString cTmp=_T("");
_stUrun stTmp;
vUrun.clear();
cQry=_T("Select * From urun order by adi");
//AfxMessageBox(cQry);
rsUrun->Open(_variant_t(cQry),AdoTest.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
CStringArray caTmp;
int nPs=0;
while(!rsUrun->adoEOF)
{
stTmp.cUrunAd=_T("");
stTmp.dBirimf=0;
stTmp.nDBID=0;
Holder = rsUrun->GetCollect("urunid");//id
if(Holder.vt!=VT\_NULL) stTmp.nDBID=atoi((char\*)\_bstr\_t(Holder));
Holder = rsUrun->GetCollect("adi");//name
if(Holder.vt!=VT\_NULL) stTmp.cUrunAd=(char\*)\_bstr\_t(Holder);
Holder = rsUrun->GetCollect("birimf");//cost
if(Holder.vt!=VT\_NULL) stTmp.dBirimf=atof((char\*)\_bstr\_t(Holder));
vUrun.push\_back(stTmp);
CString adi = rsUrun->GetCollect("adi");
listbo1.AddString(\_T(adi));
int gfujf = listbo1.GetItemData(listbo1.GetCount()-1);
rsUrun->MoveNext();
SO here is the code, could you please help me on how can I get the listbox item's id in order to use it in an update query?? Here is my button below, I did some work on it but seems no good :(
void CTestADSSQLDlg::OnBnClickedButton1()
{
_RecordsetPtr rsUrun;
rsUrun.CreateInstance(__uuidof(Recordset));
CString cQry=_T("Update urun set adi='%s' where urunid='%d'", editbo1;
rsUrun->Open(_variant_t(cQry),AdoTest.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
}