CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Errors Ocurred

  1. #1
    Join Date
    May 2001
    Posts
    10

    Errors Ocurred

    Somebody knows what is the error??

    Errors ocurred -2147217887 (80040e21)

    Im getting this error when I try to update an ADO recordset... This error has no references in VB Help...


  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Errors Ocurred

    Post up your update code. It might have something to do with the SQL statement or the ADO object.

    -Cool Bizs

    Good Luck,
    -Cool Bizs

  3. #3
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Errors Ocurred

    If it's in the update metod of a recordset, the errormessage probably was one of these two

    update method of recordset failed
    or
    multiple step operation created errors...

    Most likely, you're violating some rule, like a primary key, unique index, no related record, or whatever.
    You could use the errors collection of the connection object to find out what really went wrong.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Errors Ocurred

    I made a search in msdn with code error (first part, not including "(xxx)" part). It comes up a lot of thing, but this I think is what you're looking for:


    '-----------from msdn january 2001
    PRB: Calculated Field Contents Cannot be Modified by ADO
    ID: Q241818


    --------------------------------------------------------------------------------
    The information in this article applies to:

    Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0
    ActiveX Data Objects (ADO), versions 2.0, 2.01, 2.1, 2.1 SP1, 2.1 SP2, 2.5, 2.6
    Microsoft SQL Server versions 6.5 Service Pack 4 and later, 7.0

    --------------------------------------------------------------------------------


    SYMPTOMS
    Trying to modify the contents of a calculated field within an ActiveX Data Objects (ADO) recordset, generates the following error:

    Runtime error '-2147217887(80040e21)' errors occurred.



    CAUSE
    Each calculated field in an ADO recordset contains the following attributes:



    adFldUnknownUpdatable = False

    -and-


    adFldUpdatable = False


    This indicates that the field cannot be modified.



    RESOLUTION
    Here are two ways to work around this behavior:

    Use the Shape command to append a field into the ADO recordset.

    -or-


    Use the calculated field for display purposes only without modifying its contents.





    STATUS
    This behavior is by design.



    MORE INFORMATION
    NOTE: Setting the adFldUnknownUpdatable and adFldUpdatable attribute flags is provider dependent. If the provider does not set the flags as indicated previously, you get a run-time error when you try to save the record.

    The sample code below uses the publishers table in the pubs database that ships with SQL Server.

    Steps to Reproduce Behavior
    Start a new Visual Basic project. Form1 is created by default. Create a reference to the Microsoft ActiveX Data Objects 2.x Library.


    Paste the following code in the General Declaration section of Form1:



    Option Explicit
    Dim con As New ADODB.Connection
    Dim rs As New ADODB.Recordset

    Private Sub Form_Load()

    ' Connection String to your SQL Server
    con.ConnectionString = "Provider=SQLOLEDB.1;Data Source=sequel;User ID=sa;Password=;Initial Catalog=pubs;"
    con.Open

    rs.CursorLocation = adUseClient
    ' Concatenate a character 'A' onto the value retrieved from the field pub_name.
    rs.Open "SELECT pub_name + 'A' AS PN FROM Publishers", con, adOpenStatic, adLockBatchOptimistic, adCmdText

    MsgBox rs.RecordCount

    Debug.Print rs(0).Attributes And adFldUnknownUpdatable, _
    rs(0).Attributes And adFldUpdatable

    rs(0) = "Hello" ' <----- ERROR OCCURS HERE

    MsgBox "Passed!"

    End Sub
    The code prints FALSE for each of the flags, adFldUnknownUpdatable and adFldUpdatable, indicating that the field is known to be non-updateable.


    NOTE: Calculated columns are also read-only in Data Access Objects (DAO) and Remote Data Objects (RDO).



    REFERENCES
    For more information on how to use the Shape command to append a field to an ADO recordset, please refer to the following article in the Microsoft Knowledge Base:

    Q223771 PRB: Appending Fields to a Recordset Generates an Error
    © Microsoft Corporation 1999, All Rights Reserved.
    Contributions by Ammar Abuthuraya, Microsoft Corporation


    Additional query words: error -2147217887(80040e21)

    Keywords : kbADO kbDatabase kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 kbCodeSnippet kbMDAC260 kbADO260
    Version : WINDOWS:2.0,2.01,2.1,2.1 SP1,2.1 SP2,2.5,2.6,5.0,6.0; winnt:6.5 Service Pack 4 and later,7.0
    Platform : WINDOWS winnt
    Issue type : kbprb
    Technology : kbvcSearch


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Errors Ocurred

    Run-time error '-2147217887(800040e21)'
    Miltiple step OLE DB operation generated errors. Check each OLE DB status value, if available.
    No work was done


    This error was generated when i was trying to enter null field to AS/400 database. When I modified these
    fields to 0, error stopped being generated. CHeck if there illegal null you are trying to write to db.
    To catch this error, disable error handler, run the prog end push debug. It will show you the field
    where an error occured.

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  6. #6
    Join Date
    Sep 2000
    Posts
    200

    Re: Errors Ocurred

    Hi Iouri,

    I had same error. To disable error handling, I entered On Error GoTo 0 in the Save procedure where the error occurred. When I press Debug, I do not get any more information. Is there something else I must do to disable error handling?

    Thanks,
    JR


  7. #7
    Join Date
    Nov 2001
    Location
    Germany
    Posts
    5

    Re: Errors Ocurred

    Hi
    I get this Error when I connect.
    Err.Number = 0
    ADOConnection.State = 1
    But
    ADOConnection.Errors.Count=1
    ADOConnection.NativeError=0
    ADOConnection.Number = -2147217887

    How can step the OLE DB operation to check the OLE DB status values and find the reason?

    Ellen





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured