"Data provider or other service returned an E_FAIL status" accessing particular table using ADO


  • Please can you help?


    I am accessing some tables using ADODB and when accessing a certain table I am getting the error message "OLE IDispatch exception code 0 from Microsoft Cursor Engine: Data provider or other service returned an E_FAIL status..."


    This occurs when I use

    ? loRS.RecordCount



    or after 56 loops of the following code


    ? loRS.Fields("cn_ref").Value

    loRS.MoveNext()  && This is the line that causes the error on the 56th loop



    The code works pefectly fine on all other tables and on a completely different data set that I have tried. I would therefore think this is some sort of data corruption but the table looks absolutely fine and foxfix can find nothing wrong with the table either. I have tried reindexing and packing the table but the problem persists so I am asking for help here please.


    My code being used is:


    LOCAL loRS AS ADODB.Recordset


    loRS = CREATEOBJECT("ADODB.Recordset")

    loConnection = CREATEOBJECT("ADODB.Connection")

    lcConnectionString = "provider=vfpoledb;data source=c:\documents and settings\all users\application data\pegasus\server vfp\data\compm\comp_m.dbc"

    loConnection.ConnectionString = lcConnectionString


    loRS = CREATEOBJECT("ADODB.Recordset")

    loRS.ActiveConnection = loConnection

    loRS.CursorType = 3

    loRS.Source = "cname"

    loRS.CursorLocation = 3


    ? loRS.RecordCount && This line causes the error

    loRS.Sort = "cn_desc" && This line causes the error

    lnRecord = 0


    lnRecord = lnRecord + 1

    ? TRANSFORM(lnRecord) +" " + loRS.Fields("cn_ref").Value

    loRS.MoveNext()  && This line causes the error



    Wednesday, August 01, 2007 10:58 AM


All replies

  • Do you have errors without "red" lines?

    Wednesday, August 01, 2007 6:08 PM
  • I get the error if any one of the red lines is present. If I remove the THIRD red line then I obviously get an infinite loop. To be fair it doesn't error but it's not great programming


    I came across a thread on where another developer had the same problem. One poster suggested using

    .CursorLocation = adUseServer

     I have done this and surprisingly I don't get the error now. Hurray!  Previously I had

    .CursorLocation = adUseClient && same as .CursorLocation = 3


    I have no idea why this fixed my problem though. Any ideas?

    • Proposed as answer by Chris M Puckett Wednesday, December 30, 2015 6:36 PM
    Thursday, August 02, 2007 2:13 PM
  • You will find some samples for client cursor and server cursor at:


    Thursday, August 02, 2007 2:24 PM
  • Thanks for that dni.

    I have tried using the sample from the article you reference above and as soon as I change it to my dataset I get the original error.


    After looking at the article you referenced I found another article that I haven't seen for sometime "ADO Jumpstart for VFP Developers" Looking at this article it says that server cursors don't support sorting, filtering or updating (which seems true in my testing) so I need a client side cursor after all. I still don't know why the client cursor fails and a server side won't support all of the features I need!

    Could it be some sort of problem with the OLEDB provider???
    Thursday, August 02, 2007 3:49 PM
  • Amazingly this worked for me when doing an ADO Access to Access recordset.

    Wednesday, December 30, 2015 6:37 PM