BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TClientDataSet -> exception: EDBClient 'Field Value Required

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Jason Summers
Guest





PostPosted: Fri Apr 30, 2004 4:53 am    Post subject: TClientDataSet -> exception: EDBClient 'Field Value Required Reply with 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's 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's 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'd 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


Back to top
Jason Summers
Guest





PostPosted: Fri Apr 30, 2004 5:07 am    Post subject: Re: TClientDataSet -> exception: EDBClient 'Field Value Requ Reply with quote



I found the answer. The TProvider is linked to a dbexpress query component.
I went into it's Fields Editor and added the fields, then set it's 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" <jason (AT) grinc (DOT) org> wrote

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's 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's 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'd 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





Back to top
Dave Rowntree
Guest





PostPosted: Fri Apr 30, 2004 9:12 am    Post subject: Re: TClientDataSet -> exception: EDBClient 'Field Value Requ Reply with quote



Have a look at this:
http://bdn.borland.com/article/0,1410,20847,00.html

It covers the use of autoinc fields but the methodology put forward
applies to what you are doing.
--
Dave Rowntree
Back to top
Himanshu Upadhyay
Guest





PostPosted: Sat May 01, 2004 11:08 am    Post subject: Re: TClientDataSet -> exception: EDBClient 'Field Value Requ Reply with quote

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" <jason (AT) grinc (DOT) org> wrote

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's 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's 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'd 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





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.