The following is a piece of code I have written to create an MS Access 97 database programmatically using PERL
# !/usr/bin/perl -w
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const;
my $dbname = 'c:/Perlscripts_Conv_Issues/mk-db/new.mdb';
if (-e $dbname) {
unlink $dbname
}
my $catalog = Win32::OLE->new('ADOX.Catalog');
$catalog->Create('Provider=Microsoft.Jet.OLEDB.3.51;'.
'Data Source='.$dbname) || die "unable to create d
+atabase -
".Win32::OLE->LastError;
my $tblNEW = Win32::OLE->new('ADOX.Table');
$tblNEW->{Name} = "Contacts";
print "created table \n";
$tblNEW->Columns->Append("FirstName", 'adVarWChar');
$tblNEW->Columns->Append("LastName", 'adVarWChar');
$catalog->Tables->Append($tblNEW);
$tblNEW = undef;
$catalog = undef;
After executing this code, The Access DB and table is created, but the fields are not created.
Can Anyone help me with this? What am i doing wrong?
jsprat - you outlined this solution for me in my previous message. Maybe you can figure this one out?
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.