Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Datasource

Status
Not open for further replies.

sveta

Programmer
May 28, 2002
16
NL
Hello
When i set DataGrid.Datasource=MyRecordset i can notice in SQL Server Profiler the work of sistem procedure sp_cursorfetch, which loads records of the table by rowset=64 records. (It takes all records of the table. Don't quite understand why it needs it)
Later when i scroll DataGrid - Recordset gets data by parts
Why does it load entire recordset when i set datasource? Can i change it? It takes quite a few time when the table is large:(
I use server cursor
Help!!!!
 
This is because the data grid requires all of the records to be local when loading, as it wants to load all records.

You need to either set the recordsets criteria or use the TOP n PERSENT in order to limit the amount of records, or pull the records in a page at a time.
See Micrsoft's Knowledgebase article: Q254117

But, what you may prefer when using the data grid is to fetch the records Asynchronously.

rs.Source = "SELECT..."
rs.Open Options:=adCmdText or adAsyncFetch

This will load the first page into the data grid immediately, and fetch the remaining records in the background.
 
Hello.
Thank you very much for answer!!!
So if i use server cursor and I bind DataGrid.Datasource with Recordset, DataGrid wanna all records to be local. There is no chanse it to load only first page? That's a pity if it is...it loads all records(as if i used client cursor) and when i change grid pages starts to load records by parts... Eh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top