WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ADO AD Sort Problem


Question:

I can't seem to figure out how to sort/filter this recordset. When I try to sort or filter I get an error "Current provider does not support the necessary interfaces for sorting or filtering." According to the ADO documentation, these functions should be available. What am I doing wrong?
objConnection = CreateObject("ADODB.Connection")
objConnection.Open("Provider=ADSDSOObject")
objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

;change these variables to alter your search
ADPath=""
filter="(&(objectCategory=Person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))"
fields="samAccountName,mail,employeeNumber,department"
scope="subtree";all children
;scope="onelevel";Immediate children
;scope="base";no subfolders

objCommand.CommandText = strCat(ADPath,";",filter,";",fields,";",scope)
objRecordSet = objCommand.Execute
objRecordSet.sort=("EmployeeNumber")

objConnection.Close

Answer:

Declare a Recordset Object, and set the cursorlocation to adUseClient. The ADO Client Cursor Engine does support the Sort method. Set the CursorLocation property of the ADO recordset object to adUseClient before opening it. Check out the following MS Knowledge base article: http://support.microsoft.com/default.aspx?scid=kb;en-us;253248 Sort sample code: http://msdn.microsoft.com/library/en-us/ado270/htm/mdprosortx.asp?frame=true
Article ID:   W16565
File Created: 2005:02:18:12:21:28
Last Updated: 2005:02:18:12:21:28