Hi. Is there somebody to explain to me what is "Cursor" and what is "CursorLocation" and how/why this property can affect the RecordCount property? I wonder for all these because I have created a recordset with .CursrorLocation=adUseServer and .CursorType=adForwardOnly but the .RecordCount did not works (the result is -1). Only if I change the .CursorLocation property to adUseClient the .RecordCount works!Why?
Okie, cursor type and cursor location determine how the recordset is build and handled and what machine is responsible for the processing of the recordset.
When you set the location to adUseClient the db server must build the entire recordset and then pass it back to whatever the client is (this may be the same machine). If the recordset is completely built then you can get the correct recordcount property. When you are using adUseServer the recordset is often incomplete. It gets added to as needed so you can't get the recordcount.
The cursor type is along the same sort of line but rather then telling it what handles the cursor it says what type of cursor to use. adForwardOnly means you have a static view of the records and you can't go backwards through the recordset. This means that you can move through the recordset faster but only in one direction. Other cursor types will allow you to do different things but may be slower and the recordset may be larger.
Does that help??
Here is a link the the cursortype page on MSDN and under that the cursorlocaiton page.