Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6885693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:39:59+00:00 2026-05-27T05:39:59+00:00

I am using a function I read about here to merge a series of

  • 0

I am using a function I read about here to merge a series of recordsets that are generated by a stored procedure that is called in a loop. I have used this function before in other stored procedure cases and it has never produced this problem.
The research I did online points to basically one of two reasons:
1) I am trying to update or insert a date/time value that is not formatted correctly into a SQL Server 2005 table
2) I am trying to insert a, for example, CHAR(60) string into a CHAR(50) field.

Reason one is not applicable here since I am not using dates (in datetime format at least).
Reason two seemed to be the most likely issue. So I did a series of Response.Write() to spit out the objField.Name, objField.Type, objField.ActualSize, and if it was a numeric field the objField.Precision and objField.NumericScale.

Let us say that the stored SQL procedure is called twice as I am querying for values that are occurring in the same time frame but 2 different states. The loop I have in the ASP page does a For Each on the state in the state list and calls the stored procedure for each of the elements in the state list. I then call the MergeRecordSets function so it combines the 2 results into one. The general rule is that the data types and sizes of the columns in each resultset must be the same. With my Response.Write() checks of each of the columns returned in the 2 data sets I have found that they are identical. Doing my checks I also found that it breaks on the first column that is a NUMERIC column. The previous columns it was OK with were all CHAR or VARCHAR.

Is there any other reason why this error would come up?

The following is how I am calling the record merger function. The oQueryResult is going to be the final output (the combined records). objSingleRS is the result set returned by the stored procedure.

If oQueryResult Is Nothing Then
    Set oQueryResult = objSingleRS
Else
    Set oQueryResult = MergeRecordSets(Array(oQueryResult, objSingleRS))
End If

Here is the merge function. The line in which the code breaks is marked below.

Function MergeRecordSets(arrRecordsets)
    Dim x, y, objCurrentRS
    Dim objMergedRecordSet, objField, blnExists
    Set objMergedRecordSet = Server.CreateObject("ADODB.Recordset")

    For x=0 To UBound(arrRecordsets)
        Set objCurrentRS = arrRecordsets(x)

        For Each objField In objCurrentRS.Fields
            blnExists = False
            For y=0 To objMergedRecordSet.Fields.Count-1
                If LCase(objMergedRecordSet.Fields(y).Name) = Lcase(objField.Name) Then
                    blnExists = True : Exit For
                End If
            Next
            If Not(blnExists) Then
                objMergedRecordSet.Fields.Append objField.Name, objField.Type, objField.DefinedSize
                'objMergedRecordSet.Fields(objMergedRecordset.Fields.Count-1).Attributes = 32 'adFldIsNullable
            End If
        Next
    Next

    objMergedRecordSet.Open

    For x=0 To UBound(arrRecordsets)
        Set objCurrentRS = arrRecordsets(x)

        Do Until objCurrentRS.EOF
            objMergedRecordSet.AddNew
            For Each objField In objCurrentRS.Fields
                If Not(IsNull(objField.Value)) Then
                    'Response.Write(objField.Name & "<br>")
                    'Response.Write(objField.Type & "<br>")
                    objMergedRecordSet.Fields(objField.Name).Value = objField.Value 'Here is where it throws the Error.
                End If
            Next
            objCurrentRS.MoveNext
        Loop
    Next

    objMergedRecordSet.MoveFirst
    Set MergeRecordSets = objMergedRecordSet
End Function

Here is the full error message returned:

Microsoft Cursor Engine error '80040e21'

Multiple-step operation generated errors. Check each status value.

/includes/funcs/Common.asp, line 4109 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:39:59+00:00Added an answer on May 27, 2026 at 5:39 am

    You mentioned that you have numeric columns, but you never set the Precision and NumericScale properties when you create the new Field in objMergedRecordSet. You need to set these properties for adNumeric and adDecimal fields.

    objMergedRecordSet.Fields.Append objField.Name, objField.Type, objField.DefinedSize
    With objMergedRecordSet.Fields(objField.Name)
        .Precision = objField.Precision
        .NumericScale = objField.NumericScale
    End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read the post here about using setTimeout() during intensive DOM processing (using
I read at Scottgu blog about using OutputCache for a function but this didn't
I am using IMoniker::BindToObject function, and I have read the article on MSDN. The
I habe read here about defining method for a Javascript class Advantages of using
I write code with Python using Django framework. Now I have read about all
What are the sql exceptions will thrown by using the following function: Read Update
I want to make some C++ program and I'm using function popen here to
I have a question regarding use of FFT. Using function getBand(int i) with Minim
In using a function, I wish to ensure that the type of the variables
Windows 7 has a (neat?) new feature called a 'virtual wireless adapter'. Read about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.