Solved

VISUAL BASIC AND ORCLE

Posted on 2002-03-06
10
319 Views
Last Modified: 2013-11-25
HI

I have a question about vb and oracle,
i have a recordset and i have a rows in
that recordset whenever i am trying
to get recordset.count i am getting
recordset.count value equals to -1.
how can i solve this please help
me in this

Thanks
abhi
0
Comment
Question by:abhis
[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
10 Comments
 
LVL 1

Expert Comment

by:RichardA
ID: 6844539
Can you post a  sample of your call to set your record set object?  What parameters are you using when you create the recordset? There are some types of recordsets that you cannot retrieve the record count such as some forward scrolling cursors.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6844559
try opening the recordset with
cursor location = adUseClient (3) and
cursor type = adOpenDynamic (2)
0
 
LVL 5

Expert Comment

by:rpai
ID: 6844573
The RecordCount property would return -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount. For a FORWARD-ONLY cursor, the RecordCount property will return -1. For a DYNAMIC cursor, either -1 or the actual count for a dynamic cursor, depending on the data source

The actual count would be returned only for a KEYSET/STATIC cursor type of recordsets.

Hope this helps.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:abhis
ID: 6844733
Hi richard this is the code
Dim strconn
    Dim objrs As New ADODB.Recordset
    Dim objconn As New ADODB.Connection
    strconn = "DSN=name;UID=userid;PWD=password"
    strsql = "SELECT SEQNO2 FROM ER2_EMPLOYER"
    objconn.Open strconn
    Set objrs = objconn.Execute(strsql)
    'objrs.Open strsql, strconn, adOpenStatic
    'objrs.Open strsql, strconn, adOpenKeyset
    'Set objrs = objconn.Execute(strsql)
    MsgBox (objrs.RecordCount)
    objrs.Close
    Set objrs = Nothing
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6844859
RecordCount is not reliable in ADO, particularly for getting the number of records right after opening the recordset.

Try moving to the end of the recordset (objrs.MoveLast) and then look at the objrs.AbsolutePosition property.
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 50 total points
ID: 6845250
try this instead:

Dim strconn
   Dim objrs As New ADODB.Recordset
   Dim objconn As New ADODB.Connection
   strconn = "DSN=name;UID=userid;PWD=password"
   strsql = "SELECT SEQNO2 FROM ER2_EMPLOYER"
   objconn.CursorLocation = adUseClient
   objconn.Open strconn
   Set objrs = objconn.Execute(strsql)
   objrs.Open strsql, strconn, adOpenDynamic
   Set objrs = objconn.Execute(strsql)
   MsgBox (objrs.RecordCount)
   objrs.Close
   Set objrs = Nothing
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6845260
notice the objconn.CursorLocation = adUseClient
0
 

Author Comment

by:abhis
ID: 6845451
hi

I Solve this problem,the problem was
i am using odbc for oracle,if i use microsoft odbc for
oracle i am getting exact record count.i tried
objconn.cursorlocation in odbc for oracle the record
count is showing -1 Only.thanks for your help.

Thanks
abhi
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6862727
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY ABOUT THIS AND ALL YOUR OPEN QUESTIONS AT THIS SITE.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20100575.html
http://www.experts-exchange.com/questions/Q.20116946.html
http://www.experts-exchange.com/questions/Q.20121705.html
http://www.experts-exchange.com/questions/Q.20128637.html
http://www.experts-exchange.com/questions/Q.20172197.html
http://www.experts-exchange.com/questions/Q.20175814.html
http://www.experts-exchange.com/questions/Q.20182559.html
http://www.experts-exchange.com/questions/Q.20219898.html
http://www.experts-exchange.com/questions/Q.20243643.html
http://www.experts-exchange.com/questions/Q.20273999.html
http://www.experts-exchange.com/questions/Q.20274917.html
http://www.experts-exchange.com/questions/Q.20276523.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20003690.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6957268
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

729 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