Solved

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

Posted on 2009-04-14
4
366 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 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 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

707 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