Solved

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

Posted on 2009-04-14
4
328 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
4 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 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 142

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now