Solved

How to Create a Access Table that can accept Null value

Posted on 2002-06-24
7
185 Views
Last Modified: 2010-04-04
Below are part of my code ...

....
..
uses ADOX_TLB, ComObj;

procedure TForm1.Button1Click(Sender: TObject);
Var     Catalog : _Catalog;
        Table   : _Table;
        BaseName : String;
        DS      : String;
begin
    BaseName := 'C:\DATA.mdb';
    Catalog := CreateComObject(StringToGUID('ADOX.Catalog'))as _Catalog;
    DS := 'Provider=Microsoft.jet.OLEDB.4.0;Data Source='+BaseName;
    Catalog.Create(DS);
    Table := CreateComObject(StringToGUID('ADOX.Table'))as _Table;
    Table.Name := 'FILO';
    Catalog.Tables.Append(Table);
    Table.Columns.Append('CardID',adVarWChar,12);
    Table.Columns.Append('Name',adVarWChar,20);
    Table.Columns.Append('Department',adVarWChar,12);
....
..

My problem is :-
How to set the Fields type so it can accept the null value. (Do not do the Validity Check)

0
Comment
Question by:nclong
  • 3
  • 3
7 Comments
 
LVL 22

Expert Comment

by:mnasman
ID: 7103372
Hello

try this

  Table.Columns['Department'].Attributes  :=  adColNullable
0
 
LVL 2

Expert Comment

by:Griffon
ID: 7104227
Most access table seem to accept null values...

if you are haveing problems with sending null values to an access table then try setting the emptystringtonull property to enAlways.

if it was just setting it then I thought that was the default in access *shrugs*

if I am totally out of it and barking way up the wrong tree then sorry :)
0
 

Author Comment

by:nclong
ID: 7106347
To : mnasman

I'd try as u suggested, but it show the error as below :-

'EOleException Error, multiple-Step OLE DB operatio Generated Errors'

any ideas ??
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 22

Accepted Solution

by:
mnasman earned 100 total points
ID: 7106945
ok, try to add the field as this way

var
  Col : _Column;
...
  Col.Name := 'Deparament';
  Col.Attributes := adColNullable;
  Col.Type_ := adVarWChar;
  Col.DefinedSize := 12;
  Table.Columns.Append (Col, adVarWChar, 12);

Best regards
Mohammed Nasman
0
 

Author Comment

by:nclong
ID: 7109755
Thks, Mnasman. your method work fine now.
btw, do u know how to add in the Table Description ?? I'll increase the point to 200 if u can help me on this.

Regards,
Raymond

0
 
LVL 22

Expert Comment

by:mnasman
ID: 7126512
Hello Raymond

  I really tried hard to find that, even in microsoft site, there's no info about that, i just found how to read the table desc using visual basic, but not to write it



0
 

Author Comment

by:nclong
ID: 7137232
anywhere, thks for your help.

just mail it to me at raymond@asistech.com.sg if you has any idea.

Thks,

Regards,
Raymond.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now