quick question about recordsets, ADO
-
I get back from a query the result that the number of records found is 0. Immediately after I process commands with this rs. It crashes. So I want to put in an exit like if(rs has zero records) { do this return } However I dont know how to state 'rs has zero records'....in ADO. I dont see an isEmpty type function in the docs. I am using ADO. Thanks, ns
GetRows()
perhaps? (I don't know ADO). /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
I get back from a query the result that the number of records found is 0. Immediately after I process commands with this rs. It crashes. So I want to put in an exit like if(rs has zero records) { do this return } However I dont know how to state 'rs has zero records'....in ADO. I dont see an isEmpty type function in the docs. I am using ADO. Thanks, ns
Or maybe you could check its
EOF
property? (Sorry, just guessing.) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
I get back from a query the result that the number of records found is 0. Immediately after I process commands with this rs. It crashes. So I want to put in an exit like if(rs has zero records) { do this return } However I dont know how to state 'rs has zero records'....in ADO. I dont see an isEmpty type function in the docs. I am using ADO. Thanks, ns
-
When the Recordset is empty, both the BOF and EOF flags are set, so...
if (rs.IsBOF() && rs.IsEOF())
{
do this
return
}should be what you want.... Blade[DMS]
This didnt pass the compiler: IsEOF is a dao thing, EOF is not an ADO thing either. getting close though....:)
/\* if((m\_photoDb.m\_pRecordsetPhoto.BOF = TRUE) && ( m\_photoDb.m\_pRecordsetPhoto.EOF = TRUE)) { AfxMessageBox ("empty rs"); return; }\*/
Thanks for the responses, ns OOPS! I think I need ->EOF not .EOF....I'm trying it now. DArn! That wasnt it.
-
This didnt pass the compiler: IsEOF is a dao thing, EOF is not an ADO thing either. getting close though....:)
/\* if((m\_photoDb.m\_pRecordsetPhoto.BOF = TRUE) && ( m\_photoDb.m\_pRecordsetPhoto.EOF = TRUE)) { AfxMessageBox ("empty rs"); return; }\*/
Thanks for the responses, ns OOPS! I think I need ->EOF not .EOF....I'm trying it now. DArn! That wasnt it.
== not = :omg: /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
-
== not = :omg: /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
guess what - I tried that too....I really did.
Compiling...
Train1View.cpp
C:\Train1View.cpp(2473) : error C2059: syntax error : '('
C:\Train1View.cpp(2474) : error C2143: syntax error : missing ';' before '{'
C:\Train1View.cpp(2475) : error C2039: 'AfxMessageBox' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
C:\Train1View.cpp(2488) : error C2039: 'm_photoDb' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
C:\Train1View.cpp(2488) : error C2039: 'GetPhotoBuffer' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
Error executing cl.exe. -
This didnt pass the compiler: IsEOF is a dao thing, EOF is not an ADO thing either. getting close though....:)
/\* if((m\_photoDb.m\_pRecordsetPhoto.BOF = TRUE) && ( m\_photoDb.m\_pRecordsetPhoto.EOF = TRUE)) { AfxMessageBox ("empty rs"); return; }\*/
Thanks for the responses, ns OOPS! I think I need ->EOF not .EOF....I'm trying it now. DArn! That wasnt it.
I think it depends how you import the ADO code, but in my version "EOF" is renamed to "adoEOF" because of the conflict with the C EOF define for end of file returned by fgetc etc... try...
if ((m_photoDb.m_pRecordsetPhoto->BOF == TRUE)
&& (m_photoDb.m_pRecordsetPhoto->adoEOF == TRUE))
{
AfxMessageBox ("empty rs");
return;
}Blade[DMS]
-
guess what - I tried that too....I really did.
Compiling...
Train1View.cpp
C:\Train1View.cpp(2473) : error C2059: syntax error : '('
C:\Train1View.cpp(2474) : error C2143: syntax error : missing ';' before '{'
C:\Train1View.cpp(2475) : error C2039: 'AfxMessageBox' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
C:\Train1View.cpp(2488) : error C2039: 'm_photoDb' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
C:\Train1View.cpp(2488) : error C2039: 'GetPhotoBuffer' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
Error executing cl.exe.Mail me
Train1View.cpp
. Looks like you got a misplaced->
. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
I think it depends how you import the ADO code, but in my version "EOF" is renamed to "adoEOF" because of the conflict with the C EOF define for end of file returned by fgetc etc... try...
if ((m_photoDb.m_pRecordsetPhoto->BOF == TRUE)
&& (m_photoDb.m_pRecordsetPhoto->adoEOF == TRUE))
{
AfxMessageBox ("empty rs");
return;
}Blade[DMS]
-
I checked for the recordcount and used that instead. SO the original mystery is unsolved, but I have a workaround.. :)
I would be careful on how you use the recordcount method. I think this is just a water mark of the number of records you have iterated through. The count that it returns is only correct if you have iterated through the whole recordset. You have to use EOF and BOF to work out if you have any records. When you Import the ADO object you usually rename EOF to what ever you want
-
I think it depends how you import the ADO code, but in my version "EOF" is renamed to "adoEOF" because of the conflict with the C EOF define for end of file returned by fgetc etc... try...
if ((m_photoDb.m_pRecordsetPhoto->BOF == TRUE)
&& (m_photoDb.m_pRecordsetPhoto->adoEOF == TRUE))
{
AfxMessageBox ("empty rs");
return;
}Blade[DMS]
If you are using namespaces then you may need to say something like ADODB::EOF or ADODB::adEOF etc. Check the .tlh file and see what the constant is.
-
I get back from a query the result that the number of records found is 0. Immediately after I process commands with this rs. It crashes. So I want to put in an exit like if(rs has zero records) { do this return } However I dont know how to state 'rs has zero records'....in ADO. I dont see an isEmpty type function in the docs. I am using ADO. Thanks, ns
There is other way for it too.First Execute this query: select count(*) from yourtable It always return 1 record and its number of rows in table(at least it return 0 in that record),so you can find out how many records are in the table. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down
-
There is other way for it too.First Execute this query: select count(*) from yourtable It always return 1 record and its number of rows in table(at least it return 0 in that record),so you can find out how many records are in the table. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down
that is hideously inefficent. i'd just get the EOF thing working. STL is a religeon. Enquiries to Reverend Christian Graus