Board index » delphi » TClientDataSet -> exception: EDBClient 'Field Value Required.'

TClientDataSet -> exception: EDBClient 'Field Value Required.'


2004-04-30 12:53:31 PM
delphi44
IDE: Delphi 7 Enterprise
Database: Interbase 6
Problem:
In my Interbase table, I have a unique # (Primary Key) assigned to each
record. This record value is filled in with a trigger/generator
combination. The trigger is fired BEFORE INSERT:
CREATE TRIGGER SET_CLIENTS_CLIENTID FOR CLIENTS BEFORE INSERT POSITION 0 AS
BEGIN
NEW.CLIENTID = GEN_ID(GEN_CLIENTS_CLIENTID, 1);
END
The table CLIENTS is structured like this:
-----------------------------------------
CLIENTID INTEGER NOT NULL, (Primary Key)
FIRSTNAME VARCHAR(21),
LASTNAME VARCHAR(21),
... // other fields, address, city, etc.
I am using the TClientDataSet and TProvider components. The TClientDataSet
does not allow me to post a new record into it is in-memory dataset. The
first error I received is this:
Exception: EDatabaseError - Field 'CLIENTID' must have a value
I went to the TClientDataSet Fields Editor and added the TFields. I then
edited the CLIENTID TField instance and set it is Required to False.
Now I get the error 'EDBClient 'Field Value Required.'
No other fields in the CLIENTS table need values; they are all fields like
first name, last name, dob, etc. None are keyed, all can be null and do not
require values.
Funny thing is, I can go ahead and give CLIENTID any value, say 99, and it
will work just fine. The trigger seems to overwrite whatever value I throw
in the TClientDataSet. I would like to be able to add records to the
ClientDataSet without setting the CLIENTID field to some fake value, since
this is the 'right' way to do it.
I've tried messing the the TFieldDefs, but I think these are only used in
CreateDataSet method, and since my dataset is already created these didn't
seem to help either.
I've tried linking the TProvider to bother dbExpress and Interbase Express.
I don't think these matter, since it won't let me post to the ClientDataSet
anyways.
Thanks for help in advance
- Jason
 
 

Re:TClientDataSet -> exception: EDBClient 'Field Value Required.'

I found the answer. The TProvider is linked to a dbexpress query component.
I went into it is Fields Editor and added the fields, then set it is CLIENTID
TField instance Required property to False. Now it works fine.
I still don't understand why it works now works. I know the TClientDataSet
gets its FieldDefs from this dataset, but I overwrote the Required property
in the ClientDataSet.
- Jason
"Jason Summers" <XXXX@XXXXX.COM>writes
Quote
IDE: Delphi 7 Enterprise
Database: Interbase 6

Problem:
In my Interbase table, I have a unique # (Primary Key) assigned to each
record. This record value is filled in with a trigger/generator
combination. The trigger is fired BEFORE INSERT:

CREATE TRIGGER SET_CLIENTS_CLIENTID FOR CLIENTS BEFORE INSERT POSITION 0
AS
BEGIN
NEW.CLIENTID = GEN_ID(GEN_CLIENTS_CLIENTID, 1);
END

The table CLIENTS is structured like this:
-----------------------------------------
CLIENTID INTEGER NOT NULL, (Primary Key)
FIRSTNAME VARCHAR(21),
LASTNAME VARCHAR(21),
... // other fields, address, city, etc.

I am using the TClientDataSet and TProvider components. The
TClientDataSet
does not allow me to post a new record into it is in-memory dataset. The
first error I received is this:

Exception: EDatabaseError - Field 'CLIENTID' must have a value

I went to the TClientDataSet Fields Editor and added the TFields. I then
edited the CLIENTID TField instance and set it is Required to False.

Now I get the error 'EDBClient 'Field Value Required.'
No other fields in the CLIENTS table need values; they are all fields like
first name, last name, dob, etc. None are keyed, all can be null and do
not
require values.

Funny thing is, I can go ahead and give CLIENTID any value, say 99, and it
will work just fine. The trigger seems to overwrite whatever value I
throw
in the TClientDataSet. I would like to be able to add records to the
ClientDataSet without setting the CLIENTID field to some fake value, since
this is the 'right' way to do it.

I've tried messing the the TFieldDefs, but I think these are only used in
CreateDataSet method, and since my dataset is already created these didn't
seem to help either.

I've tried linking the TProvider to bother dbExpress and Interbase
Express.
I don't think these matter, since it won't let me post to the
ClientDataSet
anyways.

Thanks for help in advance
- Jason


 

Re:TClientDataSet -> exception: EDBClient 'Field Value Required.'

Same Problem i was also facing. and i found funny solution for it.
what i did it first i create table and not mark field as primary key then i
fetch all fields in my clientdataset. after that i again goto dabase and
make that field primary key. it really work fine.
himanshu
"Jason Summers" <XXXX@XXXXX.COM>writes
Quote
IDE: Delphi 7 Enterprise
Database: Interbase 6

Problem:
In my Interbase table, I have a unique # (Primary Key) assigned to each
record. This record value is filled in with a trigger/generator
combination. The trigger is fired BEFORE INSERT:

CREATE TRIGGER SET_CLIENTS_CLIENTID FOR CLIENTS BEFORE INSERT POSITION 0
AS
BEGIN
NEW.CLIENTID = GEN_ID(GEN_CLIENTS_CLIENTID, 1);
END

The table CLIENTS is structured like this:
-----------------------------------------
CLIENTID INTEGER NOT NULL, (Primary Key)
FIRSTNAME VARCHAR(21),
LASTNAME VARCHAR(21),
... // other fields, address, city, etc.

I am using the TClientDataSet and TProvider components. The
TClientDataSet
does not allow me to post a new record into it is in-memory dataset. The
first error I received is this:

Exception: EDatabaseError - Field 'CLIENTID' must have a value

I went to the TClientDataSet Fields Editor and added the TFields. I then
edited the CLIENTID TField instance and set it is Required to False.

Now I get the error 'EDBClient 'Field Value Required.'
No other fields in the CLIENTS table need values; they are all fields like
first name, last name, dob, etc. None are keyed, all can be null and do
not
require values.

Funny thing is, I can go ahead and give CLIENTID any value, say 99, and it
will work just fine. The trigger seems to overwrite whatever value I
throw
in the TClientDataSet. I would like to be able to add records to the
ClientDataSet without setting the CLIENTID field to some fake value, since
this is the 'right' way to do it.

I've tried messing the the TFieldDefs, but I think these are only used in
CreateDataSet method, and since my dataset is already created these didn't
seem to help either.

I've tried linking the TProvider to bother dbExpress and Interbase
Express.
I don't think these matter, since it won't let me post to the
ClientDataSet
anyways.

Thanks for help in advance
- Jason