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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a DataCombo control's ADODC recordset be sorted

Status
Not open for further replies.

aldovalerio

Programmer
Mar 29, 2001
36
CH
VB 6.0; ADO 2.6. I have a DataCombo control bound to an Adodc. I programmatically create a recordset from a stored procedure, and assign the recordset to the adodc: Set Adodc.Recordset = rst. Then I set the rst to nothing. I would then like to sort the DataCombo's data with the recordset sort method. If I sort the rst that I return the stored proc. to, it works fine, but when I assign it to the adodc, it loses it's sort. My adodc properties are: CursorLocation=adUseClient, CursorType=adOpenStatic, LockType=adLockReadOnly, Mode=adModeRead. Since I'm destroying the rst after assigning it to the adodc, I'm wondering if these property settings have any effect; given that there is no persistent db connection. My objective in using an ADO sort is to reduce the number of stored procs. calls (and db traffic), since 2 of them return the same results; just with a different SQL "ORDER BY" clause.
 
According to Microsoft's KnowledgeBase, this is due to a VB bug: "DataCombo/DataList Not Displaying Recordset with Sort/Filter (Q230167)". The suggested workaround is to sort the recordset, create a new recordset, and read the sorted one into the new one record by record. I've tested this and it works, although the added processing time eliminates any gain that I'd hoped for in sorting the recordset, rather than just issuing another SQL command with an "ORDER BY" clause.

I've also seen a proposed solution using a PropertBag, but it didn't work for me. Maybe I didn't implement it correctly:
Dim pbg as PropertyBag, rst as ADODB.recordset, _
rstSorted as ADODB.recordset
Set rst = ... retrieve a recordset ...
Set rstSorted = New ADODB.Recordset
rst.Sort = "SUPPLIER_NAME"
Set pbg = New PropertyBag
pbg.WriteProperty "sorted", rst
Set rstSorted = pbg.ReadProperty("sorted")

It seems to only point to the original recordset, as does the Clone method; neither of which provide a sorted recordset to an ActiveX control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top