?
Solved

VB6 Recordset is empty when records exist in my View because of Group By

Posted on 2009-04-14
4
Medium Priority
?
370 Views
Last Modified: 2013-11-27
Hi
I'm programming with VBA for Excel, and I have a SELECT instruction that returns -1 RecordCount.

Here is my Slect Instruction :
RsPortes.Open "Select SONumber, NumSection, Qty, UniteMesure, ItemNumber, ItemName, DFTPICKINGLISTOPR FROM V_Portes WHERE V_Portes.SONumber='" & NumJob & "'", MaConnectionAxaptaData, adOpenDynamic, adLockOptimistic

The V_Portes is an SqlServer2005 view that is build with a Group By, it is working fine and getting the right results.

How can I get my recordset lines within VBA Excel code ?

Thanks  


0
Comment
Question by:venmarces
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 2000 total points
ID: 24142510
RsPortes.RecordCount is unreliable when you use adOpenDynamic.

If you just need to see whether there are rows, use RsPortes.EOF.

You can change to an adOpenStatic and adLockReadOnly and get RecordCount to behave -- assuming you don't need to write back to the recordset.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24142519
>that returns -1 RecordCount
that happens because you open on ServerSide instead of ClientSide cursor location, usually.

anyhow, do you really need the recordcount itself, or just if there are records or not => use bof and eof instead.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24143733
And in case you did not get the message:  The RecordCount property should not be used.
0
 

Author Closing Comment

by:venmarces
ID: 31570155
When I needed to get the RcordCount value of my Cursor I changed for adOpenStatic, adLockReadOnly and I was able to get the right value
Thanks for everybody  
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question