Board index » delphi » Changing the field type in a Access Database using DAO

Changing the field type in a Access Database using DAO

I am wanting to change the field type of a field in an Access Database, it
has data and anywhere up to 1500 records in the table.

I want to change the data type of the field from a Text to a Long Integer.

Does anyone know how?, I would like to use DAO to do it.

Chris Crowe
Ch...@Adrock.com
Want a free tool to help search the Microsoft BB and Search pages?, goto
http://www.adrock.com/msarticle

 

Re:Changing the field type in a Access Database using DAO


Quote
Chris Crowe <Ch...@Adrock.COM> wrote in message

news:7udi6u$avp2@forums.borland.com...

Quote
> I am wanting to change the field type of a field in an Access Database, it
> has data and anywhere up to 1500 records in the table.

I believe you can do this with ADOX (documented in the MDAC 2.1 SDK help file).

However, unless there is some reason why you need to do this programmatically in
code, I'm sure it would be much easier to just open the database in Access and
change it there.

Mark

Re:Changing the field type in a Access Database using DAO


I am sure that opening access is a better method, but when you have to
modify the database structure with new releases of your software
progmatically is the only way.

The only way I found to do it was this

1) create a new field "TempField", of the required data type
2) Do an update query to copy the original field to the new field.
3) Delete the original field
4) create a new field with the original name, and the new data type
5) Do an update query to copy the data from the TempField to the new field.
6) Delete the temp field.

It is a bit of work, but it works well enough, some of the clients have
300,000 records in the table, and it does it quite fast.

All I wanted was to change the field from a TEXT to a NUMBER...
--
Chris Crowe
Want a free tool to help search the Microsoft KB and Search pages?
goto http://www.adrock.com/msarticle (Last Update: 19th October))

Mark Edington (Borland) <meding...@nolunchmeat.com> wrote in message
news:7ugdlm$57u11@forums.borland.com...

Quote
> Chris Crowe <Ch...@Adrock.COM> wrote in message
> news:7udi6u$avp2@forums.borland.com...

> > I am wanting to change the field type of a field in an Access Database,
it
> > has data and anywhere up to 1500 records in the table.

> I believe you can do this with ADOX (documented in the MDAC 2.1 SDK help
file).

> However, unless there is some reason why you need to do this
programmatically in
> code, I'm sure it would be much easier to just open the database in Access
and
> change it there.

> Mark

Other Threads