PROBLEM: Sorting data 
Author Message
 PROBLEM: Sorting data

Dear Friend:

I'm trying to sort data in a datagrid control using an ADO
recordset.

The following is the a portion of the program.

It uses the OnHeadClick event from a datagrid to use the
put_Sort method of a recordset(pADORecordset) so that data
would be sorted everytime one clicks on the grid's header
and gets organized accordingly. BUT IT DOESN'T SORT.

Any suggestions?

void CFORMVIEW_SomeForm::OnHeadClickDatagrid(short
ColIndex)
{
    if (pADORecordset->State != adStateOpen) return;
    CString ColumnName = m_Datagrid.GetColumns().GetItem
((_variant_t)ColIndex).GetCaption();
    BSTR resultsString = ColumnName.AllocSysString();
    pRstConsulta->put_Sort(resultsString);  
    Datagrid.Refresh();

Quote:
}

THANK YOU.


Sun, 27 Mar 2005 07:12:31 GMT  
 PROBLEM: Sorting data

Quote:
> Dear Friend:

> I'm trying to sort data in a datagrid control using an ADO
> recordset.

> The following is the a portion of the program.

> It uses the OnHeadClick event from a datagrid to use the
> put_Sort method of a recordset(pADORecordset) so that data
> would be sorted everytime one clicks on the grid's header
> and gets organized accordingly. BUT IT DOESN'T SORT.

> Any suggestions?

> void CFORMVIEW_SomeForm::OnHeadClickDatagrid(short
> ColIndex)
> {
>     if (pADORecordset->State != adStateOpen) return;
>     CString ColumnName = m_Datagrid.GetColumns().GetItem
> ((_variant_t)ColIndex).GetCaption();
>     BSTR resultsString = ColumnName.AllocSysString();
>     pRstConsulta->put_Sort(resultsString);
>     Datagrid.Refresh();
> }

> THANK YOU.

Rick - there is an article about the Sort property on msdn.microsoft.com -

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado2...
mdprosortpropertyado.asp

It seems from this article that you need to set the CursorLocation property
to adUseClient before you sort the data.

Hope this helps.

--
Michael Park and Jonathan Caves
Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.



Mon, 28 Mar 2005 02:52:39 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. PROBLEM: Sorting Data

2. Sort doesn't work on bound data

3. Sorting, Algorithms, Data Structure, and Libraries

4. sorting techniques for differnt data types?

5. sort data alphabetically

6. Newbie: get and sort data from a file

7. Swaping Pointers to data structures in sorting algorithm

8. Sorting Binary data in C

9. Who to pass data to string sort function?

10. Sorting > 64K data

11. Sort Data in DataList ADO

12. Field data truncated using a sorted CRecordset

 

 
Powered by phpBB® Forum Software