Solved

VISUAL BASIC AND ORCLE

Posted on 2002-03-06
10
315 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 70
Is IHttpActionResult a promise pattern? 2 67
Visual Studio 2005 text editor 10 39
SSRS troubles 4 52
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

832 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