Hi there all again! This time with an improvement! (and more clear question about C++ ADO) :)
-
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);
} -
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);
}symeramon wrote:
CString cQry=_T("Update urun set adi='%s' where urunid='%d'", editbo1;
Seems a parenthesis has gone AWOL.
symeramon wrote:
SO here is the code, could you please help me on how can I get the listbox item's id...
Umm, since you are using MFC, why not just assign it a
CListBox
member variable? Use ClassWizard (or equivalent)."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
symeramon wrote:
CString cQry=_T("Update urun set adi='%s' where urunid='%d'", editbo1;
Seems a parenthesis has gone AWOL.
symeramon wrote:
SO here is the code, could you please help me on how can I get the listbox item's id...
Umm, since you are using MFC, why not just assign it a
CListBox
member variable? Use ClassWizard (or equivalent)."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Thanks David, at least you answered my question... But the main problem is how can I get the id from vector to use it in the button click event?
symeramon wrote:
But the main problem is how can I get the id from vector...
What does a vector have to do with any of this?
symeramon wrote:
...use it in the button click event?
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
ON_BN_CLICKED(IDC_SOME_BUTTON, OnButtonClicked)
END_MESSAGE_MAP()
...
void CMyDialog::OnButtonClicked()
{
m_listbox.AddString(_T("Hello World!"));
}"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
symeramon wrote:
But the main problem is how can I get the id from vector...
What does a vector have to do with any of this?
symeramon wrote:
...use it in the button click event?
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
ON_BN_CLICKED(IDC_SOME_BUTTON, OnButtonClicked)
END_MESSAGE_MAP()
...
void CMyDialog::OnButtonClicked()
{
m_listbox.AddString(_T("Hello World!"));
}"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous