FIX: Error Setting Sort to Char Field Greater than 255 (189837)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.0

This article was previously published under Q189837

SYMPTOMS

When you use an ADO recordset object, you cannot Sort on a field with more than 255 characters. Attempting to sort on a field with more that 255 characters results in the following error:
Run-time error '-2147217824 (80040e60)': The requested order could not be opened
You also see this error on attempting to sort on a SQL Server Text field, a Microsoft Access Memo field, or other Binary Large Object (BLOB) field.

With ADO 2.1 Service Pack 2 and later, this error does not occur on attempting to sort on a field with more than 255 characters. However, this error does occur on attempting to sort on a Binary Large Object (BLOB) field.

STATUS

This problem has been fixed in MDAC version 2.1 and later.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Visual Basic and create a Standard EXE Project.
  2. On the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects 2.0 Library.
  3. Place the following code in the Load Event of the form. Note that "Description" is a Memo field in the Categories table of the Nwind.MDB database that comes with Visual Basic:
       Private Sub Form_Load()
             Dim rs1 As New ADODB.Recordset
             Dim rs2 As New ADODB.Recordset
             Dim cn As New ADODB.Connection
             Dim rs3 As New ADODB.Recordset
    
             
    rs1.Fields.Append "F1", adInteger
             rs1.Fields.Append "F2", adChar, 255
             rs1.Open
             rs1.Sort = "F2" '<==  This works
             rs2.Fields.Append "F1", adInteger
             rs2.Fields.Append "F2", adChar, 256
             rs2.Open
             rs2.Sort = "F2" '<==  Error occurs here, ADO 2.0 or earlier
                
         End Sub
    					
  4. Press the F5 key to run the code.
RESULT: The following error message appears:
Run-time error '-2147217824 (80040e60)': The requested order could not be opened

Modification Type:MinorLast Reviewed:3/2/2005
Keywords:kbbug kbDSupport kbMDACNoSweep KB189837