Can't create a PARADOX file and insert records using ODBC
Can't create a PARADOX file and insert records using ODBC.
Using ODBC and MS Visual C++ 6.0 I am trying to create a Paradox (5.0) table
and
Insert records. I use SQL statements through SQLExecDirect().
The Jet Engine is 4.0 Service Pack6. Borland Database Engine (BDE) is also
present.
In order to insert records into a Paradox table there must be a primary key.
When I try to create the primary key in the CREATE TABLE statement (either
at the
field level or at the table level):
CREATE TABLE MyTableName (RecordID AUTOINC PRIMARY KEY, Field1 CHAR(1), ...);
or
CREATE TABLE MyTableName (RecordID AUTOINC, Field1 CHAR(1), ... PRIMARY KEY(RecordID);
I am told that the name is not valid, however, instead of displaying my field
name,
it displays a ramdom name that looks like a registry key.
Trying an alternate route, I successfully execute CREATE TABLE but specify
no PRIMARY KEY.
I then use
CREATE UNIQUE INDEX MyTableName ON MyTableName (RecordID)
or
CREATE UNIQUE INDEX MyTableName ON MyTableName (RecordID) WITH PRIMARY
The first time I execute either of them after opening up the data source
I get the
error message "Could not find field." After that (even after dropping and
recreating
the table) I am told that "This operation cannot be performed on a Paradox
table without
a primary key."
I therefore attempted to add a primary key as follows:
ALTER TABLE MyTableName ADD PRIMARY KEY (RecordID)
The first time I exectute this after connecting to the data source I am told
"Index[here follows a long string of seemingly random characters] is not
a valid name."
After that: "This operation cannot be performed on a Paradox table without
a primary key."
Thanks for your help.
Steve Oliver
soliver@planning.nyc.gov