Solved

How to Create a Access Table that can accept Null value

Posted on 2002-06-24
7
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Accepted Solution

by:
Mohammed Nasman 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:Mohammed Nasman
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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