Error on Sort for Local Recordset 
Author Message
 Error on Sort for Local Recordset

Could it be that .Sort cannot be used with locally constructed recordsets?

I'm getting an "order cannot be opened" error when trying to apply a sort on
a recordset that I constructed programatically (rather than by a database
query).

The recordset's settings are as follows.
        .CursorType = adOpenStatic
        .LockType = adLockBatchOptimistic
        .CursorLocation = adUseClient

The recordset is populated and operational.  All works fine except this one:

     .Sort "collab ASC"

'I have confirmed that the field name is correct.

Any thoughts?  - Josh



Sun, 13 Jul 2003 01:34:41 GMT  
 Error on Sort for Local Recordset

Try:

Quote:
>      .Sort = "collab ASC"



Sun, 13 Jul 2003 22:53:30 GMT  
 Error on Sort for Local Recordset
In a pre-SP4 version of VB6, you could not sort on an adBSTR field.
The sort field had to be of type adChar.

That may still be an issue....

However, other than that, I have had no trouble sorting on a
disconnected, "constructed" dataset.

Quote:

> Could it be that .Sort cannot be used with locally constructed recordsets?

> I'm getting an "order cannot be opened" error when trying to apply a sort on
> a recordset that I constructed programatically (rather than by a database
> query).

> The recordset's settings are as follows.
>         .CursorType = adOpenStatic
>         .LockType = adLockBatchOptimistic
>         .CursorLocation = adUseClient

> The recordset is populated and operational.  All works fine except this one:

>      .Sort "collab ASC"

> 'I have confirmed that the field name is correct.

> Any thoughts?  - Josh



Mon, 14 Jul 2003 03:43:17 GMT  
 Error on Sort for Local Recordset
sorry for the mistype. I did in fact have

    .Sort = "collab ASC"

Quote:
----- Original Message -----
From: <Doru Roman>

Newsgroups: microsoft.public.vb.database.ado
Sent: Wednesday, January 24, 2001 9:53 AM
Subject: Re: Error on Sort for Local Recordset

> Try:
> >      .Sort = "collab ASC"



Sun, 20 Jul 2003 01:17:02 GMT  
 Error on Sort for Local Recordset


Fri, 19 Jun 1992 00:00:00 GMT  
 Error on Sort for Local Recordset
I installed SP4, but that did not solve the problem. Thanks for trying, Art.

I have found a solution!  I checked the .Type on the fields that were being
returned from queries to the database. (I'd just assumed they were adBSTR.)
Turns out they are .Type = 202, aka adVarWChar - Indicates a null-terminated
Unicode character string (Parameter object only).

So I changed my locally defined recordset's fields from adBSTRs to
adVarWChars and now VB doesn't complain about my .Sort.


Quote:
> In a pre-SP4 version of VB6, you could not sort on an adBSTR field.
> The sort field had to be of type adChar.

> That may still be an issue....

> However, other than that, I have had no trouble sorting on a
> disconnected, "constructed" dataset.


> > Could it be that .Sort cannot be used with locally constructed
recordsets?

> > I'm getting an "order cannot be opened" error when trying to apply a
sort on
> > a recordset that I constructed programatically (rather than by a
database
> > query).

> > The recordset's settings are as follows.
> >         .CursorType = adOpenStatic
> >         .LockType = adLockBatchOptimistic
> >         .CursorLocation = adUseClient

> > The recordset is populated and operational.  All works fine except this
one:

> >      .Sort "collab ASC"

> > 'I have confirmed that the field name is correct.

> > Any thoughts?  - Josh



Sun, 20 Jul 2003 01:21:09 GMT  
 Error on Sort for Local Recordset
Joshua,
Here is a handy chart for the ADO Data Type mapping
http://www.able-consulting.com/ADODataTypeEnum.htm

--

Thanks,
Carl Prothman
Microsoft Visual Basic MVP
http://www.able-consulting.com


Quote:
> I installed SP4, but that did not solve the problem. Thanks for trying,
Art.

> I have found a solution!  I checked the .Type on the fields that were
being
> returned from queries to the database. (I'd just assumed they were
adBSTR.)
> Turns out they are .Type = 202, aka adVarWChar - Indicates a
null-terminated
> Unicode character string (Parameter object only).

> So I changed my locally defined recordset's fields from adBSTRs to
> adVarWChars and now VB doesn't complain about my .Sort.



> > In a pre-SP4 version of VB6, you could not sort on an adBSTR field.
> > The sort field had to be of type adChar.

> > That may still be an issue....

> > However, other than that, I have had no trouble sorting on a
> > disconnected, "constructed" dataset.


> > > Could it be that .Sort cannot be used with locally constructed
> recordsets?

> > > I'm getting an "order cannot be opened" error when trying to apply a
> sort on
> > > a recordset that I constructed programatically (rather than by a
> database
> > > query).

> > > The recordset's settings are as follows.
> > >         .CursorType = adOpenStatic
> > >         .LockType = adLockBatchOptimistic
> > >         .CursorLocation = adUseClient

> > > The recordset is populated and operational.  All works fine except
this
> one:

> > >      .Sort "collab ASC"

> > > 'I have confirmed that the field name is correct.

> > > Any thoughts?  - Josh



Sun, 20 Jul 2003 02:32:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Recordset.Sort and Error -7711

2. RecordSet.Sort cause error -7711

3. Sorting a recordset I created error

4. Sorting a recordset based on another recordset

5. On local error resume next Vs on error resuem next

6. ON ERROR vs ON LOCAL ERROR

7. Recordset local to module loses object

8. Global Or Local Recordsets???

9. recordset to local variables?

10. Local recordset desynchronising!

11. Global Or Local Recordsets???

12. Assigning a Recordset field to a local variable

 

 
Powered by phpBB® Forum Software