PRB: "Too Many Columns Defined in the Rowset" Err Msg

ID: Q192141


The information in this article applies to:


SYMPTOMS

You get the following error when choosing a Recordset object:

Run-time error '-2147024882 (8007000e)' Too many columns defined in the rowset.


CAUSE

The client-cursor engine supports a maximum of 255 fields.


RESOLUTION

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


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. If the recordset contains more than 255 fields, 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 Visual Basic or Microsoft Visual Basic for Applications Project with a Form. Form1 is created by default.


  2. Add a Reference for the Microsoft ActiveX Data Objects 2.0 Library.


  3. Add a Command button named Command1 to the form.


  4. Add the following code to the form:
    
          Option Explicit
    
          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) 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.

© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Malcom Stewart, Microsoft Corporation

Additional query words: kbADO kbVBp500 kbVBp600 kbDatabase


Keywords          : kbADO kbDatabase kbVBp500 kbVBp600 
Version           : WINDOWS:1.5,2.0,5.0,6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: June 7, 1999