Re: ADODB is unable to copy more than 255 chars in excel cell

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



keepITcool wrote:
> In the connection string you can set the extended property
> IMEX=1 to force mixed data types to text.
>
> That's the only way ADO/JET can READ excel cells beyond the 255 chars.
>
> However when you use the IMEX parameter (regardless if you set it to 0
> or 1... the recordset will be non updatable...
>
> I've not yet come across a solution to write long strings to excel
> files with Jet...

Jet's VARCHAR (a.k.a TEXT) data type is limited to 255 by design e.g.

CREATE TABLE [Excel 8.0;Database=C:\Test57.xls;].TestText (data_col
VARCHAR(544));

generates the error "Size of field 'data_col' is too long."

The trick is to type the Excel table as MEMO e.g.

CREATE TABLE [Excel 8.0;Database=C:\Test57.xls;].TestMemo (data_col
MEMO)
;
INSERT INTO [Excel 8.0;Database=C:\Test57.xls;].TestMemo (data_col)
VALUES ('thought that bell was in my dream all in my head until the
trucks were in the yard and the fire was in my bed oh can you hear the
ringing bell telling time like time was to tell can you see the smoke
rise and curl all the way from your side of my world hush your talk
here comes the boss down off of his perch he walks the floor in cream
white shoes like we were piggin iron in church oh can you hear the
furnace hum above the shouts and all the chewing gum hear the union
priest lead the factory choirgirls singing out to your side of my
world')
;
SELECT data_col, LEN(data_col) AS length, TYPENAME(data_col) AS type
FROM [Excel 8.0;Database=C:\Test57.xls;].TestMemo
;

Unfortunately, Jet does not support CAST, from the ANSI SQL standards.
Instead, it uses the VBA functions such as Clng, CCur and CDate to
convert values between data types but provides no effective mapping
between CStr and MEMO (see the TYPENAME result in the query above). The
only way I can think to coerce a non-MEMO Excel column to read more
than 255 characters is make it the majority type for the rows used
according to the TypeGuessRows setting e.g. put a >255 string in row 1
and set TypeGuessRows to 1.

There's some notes here:

http://www.dicks-blog.com/archives/2004/06/03/external-data-mixed-data-types/

Jamie.

--

.



Relevant Pages

  • Re: How to get ADO 2.8 to obey HDR=NO ?
    ... By the way my program opens the CSV file, reads one line, and then closes the CSV file. ... Then my application constructs a connection string. ... I don't want to force the end user to put a header line in the CSV file, but the user can decide based on their own convenience. ... By the way when Excel opens the file, Excel always thinks there is no header record. ...
    (microsoft.public.data.ado)
  • Re: Cant get SQL INSERT code to work
    ... I'm not sure you can use SQL to add data to an Excel file from another ... From Access Help file (covers JET SQL): ... ' Create the connection string. ... > 'Excel file and modify the SQL statement to fit your data. ...
    (microsoft.public.access.queries)
  • Re: Excel Automation in C++/Cli
    ... the references I had been looking into some time ago. ... The death of the variant The .NET-managed languages use common data ... and the new Object type can contain other data types ... Excel 2003 PIA. ...
    (microsoft.public.office.developer.automation)
  • RE: Memos or Comments in Excel
    ... Excel doesn't have a specific Memo type. ... A cell can be set to type "Text" ...
    (microsoft.public.excel.misc)
  • RE: Loop through Excel Files and Tables
    ... I'm having some issues using the ForEach container to process multiple excel ... and trying to reuse the connection strings they built up ... The connection string format is not valid. ... Warning: 0x80019002 at Foreach Loop Container: The Execution method ...
    (microsoft.public.sqlserver.dts)