| View previous topic :: View next topic |
| Author |
Message |
Stefan Genov Guest
|
Posted: Mon Feb 06, 2006 2:03 pm Post subject: TClientDataSet constraint trouble |
|
|
Hello everyone!
The problem is that I cannot remove the constraint from the ClientDataset
while the person
is inputing data and let the server generate ID-s for the column ID of the
new rows.
I removed the attributes from TFieldDefs and TFields - InKey, Required, set
the property of the
TDatasetProveider.Constraints to false. I call
ClientDataSet.DisableConstraints.
But I still get an error - 'Field ID must have a Value' when I try to Post
changes. If I enter a value
the problem is that I have to make it unique for each new record else I get
violation of primary key constraint.
I know that Delphi components do not allow you to send a NULL value to the
server even
there is a BeforeIndsert trigger and the value would not remain NULL at the
actual insert in the DB.
So I decided that I would fill all the ID-s on the client with for example
negative values and the
trigger will generate them when it sees that they are negative.
I want to set these values at one time before I call ApplyUpdates, not on
every NewRecord.
So basically my question is - How can I disable the checks of the
TClientDataset whether a field is required and unique?
Thank you for your cooperation.
Greetings: Stefan Genov, Bulgaria |
|
| Back to top |
|
 |
Erick Sasse Guest
|
Posted: Mon Feb 06, 2006 3:02 pm Post subject: Re: TClientDataSet constraint trouble |
|
|
Stefan Genov wrote:
| Quote: | I removed the attributes from TFieldDefs and TFields - InKey,
Required, set the property of the TDatasetProveider.Constraints to
false.
|
I think you need to set Required := False in the TField of the DataSet
in the server.
--
Erick Sasse
Brazil |
|
| Back to top |
|
 |
Stefan Genov Guest
|
Posted: Mon Feb 06, 2006 3:02 pm Post subject: Re: TClientDataSet constraint trouble |
|
|
I set ClientDataset.FieldByName('ID').Required := false
but still get "Field value required" error.
"Erick Sasse" <esasse.remove (AT) nospam (DOT) yahoo.com.br> wrote in message
news:43e75854$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Stefan Genov wrote:
I removed the attributes from TFieldDefs and TFields - InKey,
Required, set the property of the TDatasetProveider.Constraints to
false.
I think you need to set Required := False in the TField of the DataSet
in the server.
--
Erick Sasse
Brazil |
|
|
| Back to top |
|
 |
Erick Sasse Guest
|
Posted: Mon Feb 06, 2006 4:02 pm Post subject: Re: TClientDataSet constraint trouble |
|
|
Stefan Genov wrote:
| Quote: | I set ClientDataset.FieldByName('ID').Required := false
but still get "Field value required" error.
|
ClientDataSet as the name says is a DataSet in the Client.
You need to set Required to False in the Server's DataSet.
What are you using to connect to you database? If it is dbExpress, you
should set the fields in your SQLDataSet or SQLQuery.
--
Erick Sasse
Brazil |
|
| Back to top |
|
 |
Stefan Genov Guest
|
Posted: Mon Feb 06, 2006 6:01 pm Post subject: Re: TClientDataSet constraint trouble |
|
|
Eric, thanks for your trying to help
I use IBX to connect to FireBird 1.5. I use TIBQuery.
I tried this:
ClientDataset.Active := false;
Query.Open;
Query.FieldByName('ID').Required := false;
ClientDataset.Active := true;
Query.Close;
Still I get the error in ClientDataset.Post :(
"Erick Sasse" <esasse.remove (AT) nospam (DOT) yahoo.com.br> wrote in message
news:43e76b37 (AT) newsgroups (DOT) borland.com...
| Quote: | Stefan Genov wrote:
I set ClientDataset.FieldByName('ID').Required := false
but still get "Field value required" error.
ClientDataSet as the name says is a DataSet in the Client.
You need to set Required to False in the Server's DataSet.
What are you using to connect to you database? If it is dbExpress, you
should set the fields in your SQLDataSet or SQLQuery.
--
Erick Sasse
Brazil |
|
|
| Back to top |
|
 |
Erick Sasse Guest
|
Posted: Tue Feb 07, 2006 1:02 pm Post subject: Re: TClientDataSet constraint trouble |
|
|
Stefan Genov wrote:
| Quote: | Still I get the error in ClientDataset.Post
|
Double click your IBQuery and add all fields, then set the Required to
False in the TField component.
--
Erick Sasse
Brazil |
|
| Back to top |
|
 |
Stefan Genov Guest
|
Posted: Tue Mar 07, 2006 12:03 pm Post subject: Re: TClientDataSet constraint trouble |
|
|
"Erick Sasse" <esasse.remove (AT) nospam (DOT) yahoo.com.br> wrote in message
news:43e896b8$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Stefan Genov wrote:
Still I get the error in ClientDataset.Post :(
Double click your IBQuery and add all fields, then set the Required to
False in the TField component.
--
Erick Sasse
Brazil
|
I solved this problem by generating unique values for the field at the
OnnewRecord event=
But now I have the same problem again and would rather find a solution :(
The way you suggest works - I also have to remove from ProviderFlags
pfInKey and
pfInWhere. But i cannot use persistent fields in my query -
it is used for many things in the code.
Setting ProviderFlags at runtime gets rid of the 'Key violation' error. I
try to set required to false
at runtime after opening the Query, it is false, gives me no error setting
it but I still get the message
'Field value Required'.
If you think there is anything i can do to solve my problem, please help!
Thank you in advance.
Regards: Stefan Genov |
|
| Back to top |
|
 |
|