Board index » delphi » Runtime modification of field defs w/ADO

Runtime modification of field defs w/ADO


I'm trying to code an import utility that will import data from CSV files.
The problem is that when making the ADO connection it doesn't always choose
the right field type for some columns.  For example, I have one column that
consists of a alphanumeric code that ADO sees as an integer field.  Any fields
with alphas become null.

I can't hard code the field definitions since the CSV files will have
different columns on a case by case basis, but if that column shows up, it
needs to be adjusted to ftString.

I've tried setting the field type explicitly (using the SetFieldType method),
but if I attempt to call the Update method on the dataset while it's open it
quite generates an exception as expected.  However, trying to close the
dataset, modifying the field type, and then re-opening it gives me subscripts
out of range errors.  Obviously, when it's closed, it doesn't have a field
list in memory.

Some days I wish I could do everything in Perl.  :-P

Anyway, anyone slain this dragon before?  Flame away if I'm missing the
obvious, but keep in mind I'm a UNIX programmer, not a Windows programmer, so
I don't know all the subtleties of this platform. . .

        --Arthur Corliss
          Gallant Technologies (


Re:Runtime modification of field defs w/ADO

On Tue, 11 Sep 2001 00:13:09 -0000, I wrote:


Okay, having banged my head against this wall for awhile, now, I get the
impression that there's no way to force the data type assignment on dynamic
field lists.  So, it would appear that the only solution is to connect to the
CSV file w/dynamic field list, create a new table object and assign a
persistent field list by iterating over the the dynamic list, and overriding
the necessary field data types.

Due to file locking I assume I'll need to close the dynamic table object
before opening the persistent one, but then I should be able to work with that
object, correct?

I'm probably going to go ahead and try this (since it's not likely I'll get a
response to this very soon), but I hope someone tells me if I'm barking up the
wrong tree before I waste too much time on this. . .

        --Arthur Corliss
          Gallant Technologies (

Other Threads