Solved

VISUAL BASIC AND ORCLE

Posted on 2002-03-06
10
312 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now