Microsoft KB Archive/192141

= PRB: "Too Many Columns Defined in the Rowset" Error Message =

Article ID: 192141

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft ActiveX Data Objects 1.5
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



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:

http://msdn2.microsoft.com/en-us/data/aa937695.aspx



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
 Create a new Standard EXE in Visual Basic. Form1 is created by default. Add a Reference for the Microsoft ActiveX Data Objects Library. Add a Command button named Command1 to the form.  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  Run the project and click the Command button. You will see the error listed in the SYMPTOMS section.</li> 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.</li></ol>

<div class="references_section">