|
From: magix on 18 May 2008 15:08 Hi, can help to amend following on - reccount - SELECT COUNT statement ? it seems wrong CRecordset rs( &db ); rs.Open(CRecordset::forwardOnly,"SELECT COUNT(*) FROM myTable WHERE SalesID='"%d"'", szBufSalesID,CRecordset::readOnly); int reccount = rs.GetRecordCount(); if (reccount = 0) // no existing record found { // do something } else { // record exists } Regards, Magix
From: magix on 19 May 2008 01:38 Hi Expert, I tried with: CString queryStr; queryStr.Format("SELECT COUNT(*) FROM myTable WHERE SalesID='%d'", szBufSalesID); rs.Open(CRecordset::forwardOnly,queryStr,CRecordset::readOnly); reccount = rs.GetRecordCount(); But reccount still return 1, eventhough there is no such SalesID in the table. Why ? I was expecting return 0 is it somehow , the return value 1 means one row has return, instead of the value ? any workaround ? Regards, Magix "magix" <magix(a)asia.com> wrote in message news:48307eb9_2(a)news.tm.net.my... > Hi, > > can help to amend following on > - reccount > - SELECT COUNT statement ? > it seems wrong > > > CRecordset rs( &db ); > rs.Open(CRecordset::forwardOnly,"SELECT COUNT(*) FROM myTable WHERE > SalesID='"%d"'", szBufSalesID,CRecordset::readOnly); > int reccount = rs.GetRecordCount(); > > if (reccount = 0) // no existing record found > { > // do something > } > else > { > // record exists > } > > Regards, > Magix >
From: magix on 19 May 2008 02:50 Issue resolved. Please ignore this. Thanks. "magix" <magix(a)asia.com> wrote in message news:48307eb9_2(a)news.tm.net.my... > Hi, > > can help to amend following on > - reccount > - SELECT COUNT statement ? > it seems wrong > > > CRecordset rs( &db ); > rs.Open(CRecordset::forwardOnly,"SELECT COUNT(*) FROM myTable WHERE > SalesID='"%d"'", szBufSalesID,CRecordset::readOnly); > int reccount = rs.GetRecordCount(); > > if (reccount = 0) // no existing record found > { > // do something > } > else > { > // record exists > } > > Regards, > Magix >
|
Pages: 1 Prev: db.ExecuteSQL( SqlString ) Next: CTabCtrl force background repaint |