| View previous topic :: View next topic |
| Author |
Message |
Jhoe Logz Guest
|
Posted: Tue Oct 03, 2006 8:11 am Post subject: Remove required fields in Access |
|
|
How can I remove the required fields in Access table using Delphi? It seems
the following is not working:
For FieldCtr:= 0 to AdoTable.Fields.Count - 1 do
AdoTable.Fields.Field[FieldCtr].Required:=False;
Whenever I checked the Access table the first field is still "Required=Yes."
Also, how to set the Allow Zero Length=True (Yes) from Delphi?
Thanks for any help. |
|
| Back to top |
|
 |
Brian Hollister Guest
|
Posted: Tue Oct 03, 2006 7:56 pm Post subject: Re: Remove required fields in Access |
|
|
I had the same issue, I think.
{03.29.06 bkh There is a bug in TCustomADODataSet.InternalInitFieldDefs that
causes the "Required" property of all TFieldDefs (and consequently all
TFields)
of an ADO dataset to always be false, even though the table fields may have
been created "NOT NULL", i.e. the field does not allow NULLs. Scanning
through
ADODB.pas I found no indication that the Required property is ever set, so
it
defaults to false.
I added the workaround listed at
http://qc.borland.com/wc/qcmain.aspx?d=6264. The
QC Entry Number is 6264.
}
hth,
brian
PS - Bear in mind i develop against MS SQL 2000. There may be a difference
due to Access, i dont recall the exact text of the QC entry.
--
Got a big event coming up? Let us
help coordinate your event. For more
visit www.kissemgoodbye.com
"Jhoe Logz" <eric (AT) smsglobal (DOT) com> wrote in message
news:452210b3 (AT) newsgroups (DOT) borland.com...
| Quote: | How can I remove the required fields in Access table using Delphi? It
seems
the following is not working:
For FieldCtr:= 0 to AdoTable.Fields.Count - 1 do
AdoTable.Fields.Field[FieldCtr].Required:=False;
Whenever I checked the Access table the first field is still
"Required=Yes."
Also, how to set the Allow Zero Length=True (Yes) from Delphi?
Thanks for any help.
|
|
|
| Back to top |
|
 |
Brian Bushay TeamB Guest
|
Posted: Wed Oct 04, 2006 6:09 am Post subject: Re: Remove required fields in Access |
|
|
| Quote: | How can I remove the required fields in Access table using Delphi? It seems
the following is not working:
For FieldCtr:= 0 to AdoTable.Fields.Count - 1 do
AdoTable.Fields.Field[FieldCtr].Required:=False;
Whenever I checked the Access table the first field is still "Required=Yes."
Delphi isn't going to change your Access database. If the table's field is |
required in Access it is going to stay that way until you change it in Access.
Normally if you have a key field as the first field in a table that field will
be required.
| Quote: |
Also, how to set the Allow Zero Length=True (Yes) from Delphi?
The only way to do this is by using ADOX which you can do if you import the ADOX |
type library.
Then you would use code like this
var
Catalog1. : Catalog;
begin
Catalog1. := CoCatalog.Create;
Catalog1._Set_ActiveConnection(ADOConnection1.ConnectionObject);
Catalog1.Tables['TheTableName'].Columns['TheColumName'].Properties['Jet
OLEDB:Allow Zero Length'].Value = True;
--
Brian Bushay (TeamB)
Bbushay (AT) NMPLS (DOT) com |
|
| Back to top |
|
 |
Jhoe Logz Guest
|
Posted: Wed Oct 04, 2006 8:44 pm Post subject: Re: Remove required fields in Access |
|
|
Brian Bushay TeamB wrote:
| Quote: | The only way to do this is by using ADOX which you can do if you import the ADOX
type library.
Then you would use code like this
var
Catalog1. : Catalog;
begin
Catalog1. := CoCatalog.Create;
Catalog1._Set_ActiveConnection(ADOConnection1.ConnectionObject);
Catalog1.Tables['TheTableName'].Columns['TheColumName'].Properties['Jet
OLEDB:Allow Zero Length'].Value = True;
|
Thanks Brian! I also used ADOX to remove the required field at
runtime while creating the Access table. |
|
| Back to top |
|
 |
|