Too many fields for Excel

P

Peter

..NET 3.5

I am using OleDb and ADO.NET to insert data into Excel spreadsheet
everything works fine until I try to add a record with 256 fields, then I
get
"Too many fields defined." error.

How can I add 256 fields?


Here's my SQL statement.

"Insert Into [Sheet1$]
(F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30,F31,F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,F50,F51,F52,F53,F54,F55,F56,F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,F75,F76,F77,F78,F79,F80,F81,F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,F100,F101,F102,F103,F104,F105,F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,F120,F121,F122,F123,F124,F125,F126,F127,F128,F129,F130,F131,F132,F133,F134,F135,F136,F137,F138,F139,F140,F141,F142,F143,F144,F145,F146,F147,F148,F149,F150,F151,F152,F153,F154,F155,F156,F157,F158,F159,F160,F161,F162,F163,F164,F165,F166,F167,F168,F169,F170,F171,F172,F173,F174,F175,F176,F177,F178,F179,F180,F181,F182,F183,F184,F185,F186,F187,F188,F189,F190,F191,F192,F193,F194,F195,F196,F197,F198,F199,F200,F201,F202,F203,F204,F205,F206,F207,F208,F209,F210,F211,F212,F213,F214,F215,F216,F217,F218,F219,F220,F221,F222
,F223,F224,F225,F226,F227,F228,F229,F230,F231,F232,F233,F234,F235,F236,F237,F238,F239,F240,F241,F242,F243,F244,F245,F246,F247,F248,F249,F250,F251,F252,F253,F254,F255,F256)
Values
(62.94176,53.27762,47.59469,39.6018,27.39624,28.76187,24.89748,24.65916,24.87506,22.36183,20.68387,21.11703,19.43238,19.95379,18.48395,18.05008,18.30268,19.40492,22.124,20.33295,21.22496,23.34776,22.35655,19.55487,21.15947,20.70817,20.0374,20.19913,20.78927,19.69869,20.2163,21.15336,21.96335,22.9129,26.22494,22.88705,22.4422,19.76273,18.22623,17.76345,18.53971,18.95599,18.90771,19.36051,21.41699,20.19919,21.34636,23.91522,24.80783,21.94726,22.45945,22.737,25.95444,25.80054,20.25189,18.36274,16.79846,18.58291,22.29139,22.16352,21.41158,21.03988,21.60466,22.71623,21.50996,21.03724,19.77541,19.97819,20.54727,19.6565,18.75263,17.41543,17.64291,18.33091,18.62344,19.85077,20.82256,21.28923,22.20907,22.72867,21.20162,20.77944,18.39044,19.23157,21.69846,20.39108,17.80639,21.12927,20.98463,20.27427,21.17315,19.06533,18.29375,19.2694,19.18989,
18.83653,24.04533,23.51943,25.14662,23.43845,22.3,21.04577,21.03441,20.68917,22.57755,20.87438,25.53831,22.90078,21.26262,20.41783,20.46618,22.27405,19.86378,20.63409,20.22434,21.12482,20.82973,21.22914,20.93445,25.31901,25.70027,27.84417,28.22738,31.75908,38.27811,42.5686,39.16324,26.58023,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
"


Thank You

Peter
 
P

Peter Morris

Can you do something like

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

Then you can perform the update in more than 1 statement, each with less
than 256 fields specified.
 
P

Peter

Peter Morris said:
Can you do something like

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

Then you can perform the update in more than 1 statement, each with less
than 256 fields specified.



--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

Unfortunately I need all 256 columns

I suppose I could do something like this, although it's not efficient and
kind of hokey, but I think it would work

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

update [Sheet1$] set F1 = 2345
where
F1 = '{a guid}'
 
P

Peter Morris

Unfortunately I need all 256 columns
I suppose I could do something like this, although it's not efficient and
kind of hokey, but I think it would work

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

update [Sheet1$] set F1 = 2345
where
F1 = '{a guid}'

In what way is that not what I suggested? I fact, I think you may even have
copied and pasted my text :)
 
P

Peter

Michael D. Ober said:
Peter said:
Peter Morris said:
Can you do something like

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

Then you can perform the update in more than 1 statement, each with less
than 256 fields specified.



--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

Unfortunately I need all 256 columns

I suppose I could do something like this, although it's not efficient and
kind of hokey, but I think it would work

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

update [Sheet1$] set F1 = 2345
where
F1 = '{a guid}'
Excel 2003 and earlier is limited to 255 columns and 65,535 rows. If you
need more, you need to use excel 2007, which supports 16,384 columns and
1,048,576 rows. These are hard limits in Excel and you cannot create
individual spreadsheets larger than these limits.

Mike.

Is that limit on OleDb in Excel, because you when you open 2003 Excel there
are 256 columns not 255
 
P

Peter

Peter Morris said:
Unfortunately I need all 256 columns

I suppose I could do something like this, although it's not efficient and
kind of hokey, but I think it would work

insert into [sheet1$] (f1) values ('{a guid}');

update [Sheet1$] set F2 = 1231, F3 = 4234
where
F1 = '{a guid}'

update [Sheet1$] set F1 = 2345
where
F1 = '{a guid}'

In what way is that not what I suggested? I fact, I think you may even
have copied and pasted my text :)



--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

I need 256 columns, your sugestion took away one of the columns.
I did not use your code and claimed as my own, what I was saying was YES I
can do what you have suggested than just add the the additional Update, to
reclaim the first column. (Notice the 'set F1').

update [Sheet1$] set F1 = 2345
where
F1 = '{a guid}'

But this solution is not very efficient, 3 updates instead of 1.
 
P

Peter

Peter said:
.NET 3.5

I am using OleDb and ADO.NET to insert data into Excel spreadsheet
everything works fine until I try to add a record with 256 fields, then I
get
"Too many fields defined." error.

How can I add 256 fields?


Here's my SQL statement.

"Insert Into [Sheet1$]
(F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30,F31,F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,F50,F51,F52,F53,F54,F55,F56,F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,F75,F76,F77,F78,F79,F80,F81,F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,F100,F101,F102,F103,F104,F105,F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,F120,F121,F122,F123,F124,F125,F126,F127,F128,F129,F130,F131,F132,F133,F134,F135,F136,F137,F138,F139,F140,F141,F142,F143,F144,F145,F146,F147,F148,F149,F150,F151,F152,F153,F154,F155,F156,F157,F158,F159,F160,F161,F162,F163,F164,F165,F166,F167,F168,F169,F170,F171,F172,F173,F174,F175,F176,F177,F178,F179,F180,F181,F182,F183,F184,F185,F186,F187,F188,F189,F190,F191,F192,F193,F194,F195,F196,F197,F198,F199,F200,F201,F202,F203,F204,F205,F206,F207,F208,F209,F210,F211,F212,F213,F214,F215,F216,F217,F218,F219,F220,F221,F222
,F223,F224,F225,F226,F227,F228,F229,F230,F231,F232,F233,F234,F235,F236,F237,F238,F239,F240,F241,F242,F243,F244,F245,F246,F247,F248,F249,F250,F251,F252,F253,F254,F255,F256)
Values
(62.94176,53.27762,47.59469,39.6018,27.39624,28.76187,24.89748,24.65916,24.87506,22.36183,20.68387,21.11703,19.43238,19.95379,18.48395,18.05008,18.30268,19.40492,22.124,20.33295,21.22496,23.34776,22.35655,19.55487,21.15947,20.70817,20.0374,20.19913,20.78927,19.69869,20.2163,21.15336,21.96335,22.9129,26.22494,22.88705,22.4422,19.76273,18.22623,17.76345,18.53971,18.95599,18.90771,19.36051,21.41699,20.19919,21.34636,23.91522,24.80783,21.94726,22.45945,22.737,25.95444,25.80054,20.25189,18.36274,16.79846,18.58291,22.29139,22.16352,21.41158,21.03988,21.60466,22.71623,21.50996,21.03724,19.77541,19.97819,20.54727,19.6565,18.75263,17.41543,17.64291,18.33091,18.62344,19.85077,20.82256,21.28923,22.20907,22.72867,21.20162,20.77944,18.39044,19.23157,21.69846,20.39108,17.80639,21.12927,20.98463,20.27427,21.17315,19.06533,18.29375,19.2694,19.18989,
18.83653,24.04533,23.51943,25.14662,23.43845,22.3,21.04577,21.03441,20.68917,22.57755,20.87438,25.53831,22.90078,21.26262,20.41783,20.46618,22.27405,19.86378,20.63409,20.22434,21.12482,20.82973,21.22914,20.93445,25.31901,25.70027,27.84417,28.22738,31.75908,38.27811,42.5686,39.16324,26.58023,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
"


Thank You

Peter

There's a 3rd party tool that works a lot better then OleDb, since you can
update any cell and it has no problem updating 256 columns.

http://www.tmssoftware.com/site/flexcel.asp
 
J

Jialiang Ge [MSFT]

Good morning everyone.

I think the error "Too many fields defined" thrown by the statement:

"Insert Into [Sheet1$] (F1,F2,F3,F4,F5, ~ ,F255,F256) Values
(62.94176,53. ~ 0,0,0,0,0,0)"

is majorly caused by a limit of Microsoft Jet database engine:
http://support.microsoft.com/kb/199076
The Microsoft Jet database engine has an internal limit of 255 fields per
query. In other words, even if the client is upgraded to Excel 2007, the
error will still be thrown.

As the KB article documented, two workarounds are:
1. Break down the update query into multiple update/insert queries.
2. Update the fields by using a recordset in Visual Basic for Applications.

Apart from them, we may also consider Office automation in this Office
related issue. Office automation will allow us to automate Excel to add
values in the specified cell ranges. But it has two weaknesses: 1.
Performance; 2. The computer that runs the app needs to be installed with
Office.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter

"Jialiang Ge [MSFT]" said:
Good morning everyone.

I think the error "Too many fields defined" thrown by the statement:

"Insert Into [Sheet1$] (F1,F2,F3,F4,F5, ~ ,F255,F256) Values
(62.94176,53. ~ 0,0,0,0,0,0)"

is majorly caused by a limit of Microsoft Jet database engine:
http://support.microsoft.com/kb/199076
The Microsoft Jet database engine has an internal limit of 255 fields per
query. In other words, even if the client is upgraded to Excel 2007, the
error will still be thrown.

As the KB article documented, two workarounds are:
1. Break down the update query into multiple update/insert queries.
2. Update the fields by using a recordset in Visual Basic for
Applications.

Apart from them, we may also consider Office automation in this Office
related issue. Office automation will allow us to automate Excel to add
values in the specified cell ranges. But it has two weaknesses: 1.
Performance; 2. The computer that runs the app needs to be installed with
Office.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

I can't use Automation because this program is part of ASP.NET project.

There's a 3rd party tool that works a lot better then OleDb, since you can
update any cell and it has no problem updating 256 columns and no Automation
needed.

http://www.tmssoftware.com/site/flexcel.asp
 
Top