![]() |
|
#1
|
|||
|
|||
|
Hi,
How can i change the size of a string field in a DBF file (Table) from my Delphi 5 program ????? Any help is a big help Thanks |
|
#2
|
|||
|
|||
|
Since you cannot restructure your table, you have to do the following:
Note: Asumming you have a table named "Employees" and a field named "LastName" and it's size is 20 and you want to change it to 30 1 - Place a tquery component on a form 2 - Write this code where you want to change the field's size With Query1 do begin sql.clear; // create a temporary field sql.add('alter table Employees add temp char(30)'); execsql; sql.clear; // copy contents of lastname to temporary field sql.add('update Employees set temp = LastName'); execsql; sql.clear; // delete field lastname sql.add('alter table Employees drop LastName'); execsql; sql.clear; // create field lastname with new size sql.add('alter table Employees add LastName char(30)'); execsql; sql.clear; // copy contents temporary field to lastname sql.add('update Employees set LastName = temp'); execsql; sql.clear; // delete temporary field sql.add('alter table Employees drop temp'); execsql; end; That's all |
![]() |
| Thread Tools | |
| Display Modes | |
|
|