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
Solved

How to Create a Access Table that can accept Null value

Posted on 2002-06-24
7
188 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: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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to call a form that is in a DLL  from an application? 13 80
Intraweb download file link ? 1 154
Delphi Yen format 3 45
Multi-layered image in FireMonkey 9 48
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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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