Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateTable fails

Status
Not open for further replies.

Ronin441

Programmer
Feb 22, 2002
128
AU
I'm doing a TTable.CreateTable.

Provided I've not used this TTable object before, it succeeds fine, but if I've previously used the TTable object to open some other table, when I hit the CreateTable, I get the error:

Project blah raised exception class EDBExceptionError with message 'Invalid parameter. Table does not exist.' Table 'C:\myfolder\Foo'. Process stopped.

The table is _not_ created. I notice that the table name listed in the error does not have a .DB extension.

Clearly some sort of state from the previous table I have opened and closed is remaining in the TTable object. Is there some particular property I should be clearing? -- Doug Burbidge mailto:dougburbidge@yahoo.com
 
Before creating a new table, you need to set DatabaseName property to a directory, you want you table to be saved in. TableName property to uhmmm a name of your new table, and TableType to type of a table. Then you need to add at least one field to your table before calling CreateTable method. Here's a small example:
Code:
...
  with ATable do // ATable is an instance of TTable 
  begin
    Active := False;
    DatabaseName := 'C:\';
    TableType    := ttParadox;
    TableName    := 'MyTable.db';
    with FieldDefs do
    begin
      Clear;
      with AddFieldDef do
      begin
        Name     := 'AFIELD';
        DataType := ftInteger;
      end;
    end;
    CreateTable();
  end;
...
Hope that helps.

--- markus
 
To answer my own question:

I was missing an
Code:
IndexDefs.Clear;
. Given the unhelpfulness of the error message, it took me quite some time to figure this out. -- Doug Burbidge mailto:dougburbidge@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top