?
Solved

How to Create a Access Table that can accept Null value

Posted on 2002-06-24
7
Medium Priority
?
196 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Accepted Solution

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

762 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