PRB: "Too Many Columns Defined in the Rowset" Error Message (192141)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 1.5
  • ActiveX Data Objects (ADO) 2.0
  • ActiveX Data Objects (ADO) 2.1 SP2
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q192141

SYMPTOMS

Running under versions of Microsoft Data Access Components (MDAC) prior to 2.5, you get the following error when choosing a Recordset object:
Run-time error '-2147024882 (8007000e)' Too many columns defined in the rowset.
Running under MDAC 2.5 and later, you get the following error:
Run-time error '-2147024882 (8007000e)': Rowsets cannot contain more than 2048 columns.

CAUSE

Prior to MDAC 2.5, the client-cursor engine supported a maximum of 255 fields.

Under MDAC versions 2.5 and later, the client-cursor engine supports a maximum of 2048 fields.

RESOLUTION

If possible, use a server-side cursor, or select fewer fields.

If you are using between 256 and 2048 fields, you may upgrade to MDAC 2.5 or later to workaround. You may download the latest version of the Microsoft Data Access Components from the following site:

STATUS

This behavior is by design. It is a design limitation of the client-cursor engine.

MORE INFORMATION

When you choose a disconnected recordset or specify a CursorLocation of adUseClient, ActiveX Data Objects (ADO) invokes the client cursor engine to handle record caching and scrolling. The cursor engine has a maximum limit of 255 fields under versions of MDAC prior to 2.5; 2048 fields under MDAC 2.5 and later. If the recordset contains more than 255 fields (2048 fields, MDAC 2.5 and later), the error listed in the SYMPTOMS section appears.

By specifying a server-side cursor, you will be able to return more fields, if your provider supports it.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Microsoft does not support modifications to this code.

The code listed in step four creates a dissociated recordset and saves the contents to disk.

Steps to Reproduce Behavior

  1. Create a new Standard EXE in Visual Basic. Form1 is created by default.
  2. Add a Reference for the Microsoft ActiveX Data Objects Library.
  3. Add a Command button named Command1 to the form.
  4. Add the following code to the form:
          Option Explicit
    
          'Change the following to 2049, to test under MDAC 2.5 and later
          Const MAX_FIELDS = 256
    
          Private Sub Command1_Click()
          Dim rs As ADODB.Recordset, I As Long
            Set rs = New ADODB.Recordset
            For I = 1 To MAX_FIELDS
              rs.Fields.Append "Field" & I, adInteger
            Next I
            rs.Open "C:\Test.Rst"
            rs.AddNew
            For I = 0 To MAX_FIELDS - 1
              rs(I) = I
            Next I
            rs.Update
            rs.Save
            rs.Close
            Set rs = Nothing
          End Sub
    					
  5. Run the project and click the Command button. You will see the error listed in the SYMPTOMS section.
  6. Change the MAX_FIELDS constant to a smaller number (range 1-255 1-2048 MDAC 2.5 and later) and re-run the project. You should not get an error.

REFERENCES

For more information about ActiveX Data Objects, please refer to your Microsoft Visual Studio documentation.

Modification Type:MinorLast Reviewed:3/2/2005
Keywords:kbDatabase kbfix kbprb KB192141