I'm query and store procedure.
After execute the query and retrieve data by using vb6.
I want to display the total rows returned from query.
I get the -1 value from recordset.recordcount.
Can anyone help me? thanks a million......
Printable View
I'm query and store procedure.
After execute the query and retrieve data by using vb6.
I want to display the total rows returned from query.
I get the -1 value from recordset.recordcount.
Can anyone help me? thanks a million......
What do you have now?, can I see the codes you are using?
It depends on the arguments you are passing when opening the recordset. Some will not suport the Recordcount property.
If your executing a SP and returning records from it to a recordset then you are creating a forward-only read-only recordset too.
i thing your table is not Primary Key that Reason for recordset can't Count the Number of Rows Insert the Primary and Run the Project if is Not Work Reply to Forums
Its not a primary key issue. Its an issue of the way the recordset is opened as only certain cursors and lock types support recordcount property.
http://support.microsoft.com/kb/194973
Thanks Roddog888 to give me some tips..
Therefore, What should I do to get the returned rows from query ?
when you create your connection like this for example:
setting the cursorlocation should solve the problem:afrog:Code:Dim con As adodb.Connection
Dim rs As adodb.Recordset
Set con = New ADODB.Connection
con.CursorLocation = adUseClient
con.Open your connection string here
Thanks Problem resolved ....
Thanks a million..
Furthermore , can someone explain to me the different btw adUseclient and adUseServer.
I hope someone can explain it to me :-)
http://msdn.microsoft.com/en-us/library/ms967908.aspx
:)
Also read this on the cursor types.
http://msdn.microsoft.com/en-us/library/aa266524.aspx
I know this is a few hours late, but I've just finished an FAQ article on the RecordCount = -1 issue, which not only explains various solutions (and the pro's/con's of them), but also why you rarely need to know the RecordCount.
I don't know if you will find it useful, but here it is: Why does Recordcount sometimes equal -1?
thanks a lot for your article , i try to read it to understand the concept ....
:-)
Si, maybe adding my two previously posted links would be a good addition to your faq. Then I wont have to favorite the ms links. ;)
I looked at them with that thought in mind (as always!), but don't think they would add much... the CursorLocation one is just a copy of the help, and CursorType is already explained in this article for ADO: What do the parameters of the recordset.Open method mean? (I think my version is easier for people to understand, but you might disagree!).