Re: ADO Recordcount = -1

From: DS (dsweatman_at_bellsouth.net)
Date: 01/25/05


Date: 25 Jan 2005 10:41:51 -0800

I am using adOpenStatic.
Deidre
Marc G wrote:
> I believe that RecordCount requires either opening the table with
> adOpenStatic or adOpenKeyset. Search in ADO 2.8 information online
for more
> information.
>
> "DS" wrote:
>
> > The following code is in a asp page. I can't get the recordcount to
> > return the correct information. The recordset is populated because
I
> > can loop through it. How do I get the recordcount to work
correctly?
> > Any help would be greatly appreciated!
> > Dim madoRs,madoCmd,msConn,msSQL
> >
> > Set madoRs = Server.CreateObject("ADODB.Recordset")
> >
> > Set madoCmd = Server.CreateObject("ADODB.Command")
> >
> > msConn = "Provider=SQLOLEDB;Data Source=XXXXXDEV;Initial
> > Catalog=TestDB;UID=xxx;PWD=xxx"
> >
> > msSQL = "select lMSDSId from tblMSDS"
> >
> > With madoRs
> > ..MaxRecords = MAX_ROWS
> > ..LockType = adLockReadOnly
> > ..CursorLocation = adUseClient
> > ..CursorType = adOpenStatic
> > End With
> >
> > With madoCmd
> > ..ActiveConnection = msConn
> > ..CommandType = adCmdText
> > ..CommandText = msSQL
> > ..CommandTimeout = 60
> > Set madoRs = .Execute
> > Set .ActiveConnection = Nothing
> > End With
> >
> > Set madoCmd = Nothing
> >
> > 'empty recordset
> > If err.number = 0 Then
> > If madoRs.RecordCount = 0 Then
> > msMsg = "There are no MSDSs matching your search criteria."
> > End If
> > End If
> >
> > Thanks,
> > Deidre
> >
> >



Relevant Pages

  • Re: Embedded SQL within VBA?
    ... but RecordCount still returned -1. ... Setting CursorType to *adOpenStatic* did the trick and now I get my ... then the provider you are using probably defaults to ... or adOpenKeyset, otherwise you may be able to use adOpenStatic. ...
    (microsoft.public.word.vba.general)
  • Re: Embedded SQL within VBA?
    ... but RecordCount still returned -1. ... Setting CursorType to *adOpenStatic* did the trick and now I get my ... then the provider you are using probably defaults to ... or adOpenKeyset, otherwise you may be able to use adOpenStatic. ...
    (microsoft.public.word.vba.general)
  • Re: Embedded SQL within VBA?
    ... If you can't MoveLast, then the provider you are using probably defaults to using an "adOpenForwardOnly" cursortype (you can use the CursorType parameter of the Open method to try to specify the CursorType, but the provider may change the type if it doesn't support the one you asked for. ... If you have an adOpenForwardONly cursor type, try changing it to any of the others - if you need to be able to update the recordset, use adOpenDynamic or adOpenKeyset, otherwise you may be able to use adOpenStatic. ... figure out why .RecordCount is returning -1 here? ...
    (microsoft.public.word.vba.general)
  • RE: ADO Recordcount = -1
    ... adOpenStatic or adOpenKeyset. ... > return the correct information. ... How do I get the recordcount to work correctly? ... > Set madoCmd = Nothing ...
    (microsoft.public.data.ado)
  • Re: Recordcount = -1 from MSDE 2K
    ... There is Microsoft documentation on RecordCount: ... Dynamic Cursor ... requested adOpenKeyset, you may have got something else if that is not ... supported for the SQL statement in question. ...
    (microsoft.public.data.ado)