luoina has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks: I am quite new in using perl. I need to create more than a hundred Access tables. I wonder if I could use Perl to create these tables. If I could, what would the code like? Thank you a lot in advance..... Young
  • Comment on How can I create Access tables with Perl?

Replies are listed 'Best First'.
Re: How can I create Access tables with Perl?
by Enlil (Parson) on Feb 18, 2004 at 05:07 UTC
    The code might look something like this:
    use strict; use warnings; use DBI; my $dbh = DBI->connect("dbi:ODBC:DSN",'username','pwd') || die "Failed to connect to database"; my $sth = $dbh->prepare("CREATE TABLE my_new_table ( [userid] integer, [entry_date] date, [true or false ] byte, [TextField] Text(25), [Long Integers] long, [Just_an_Integer] integer, [A_Memo Field] Memo, [primary_unique_key] Text(32), CONSTRAINT [Index1] PRIMARY KEY ([primary_unique_key]))" ) || die "failed to prepare"; $sth->execute() || die "failed to execute";
    -enlil
      Thank you very much!!! I will try it... Young
      Dear enlil: I tried the code and got the error message as follows, DBI connect('DSN','username',...) failed: MicrosoftODBC Driver Manager Data source name not found and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at H:\Final versions of Perl Program\accesstables.pl line 7 Failed to connect to database at H:\Final versions of Perl Program\accesstables.pl line 7. My data sourse name is "Alex", Access database name is "Estrategy". I am not sure if I should replace 'username' with 'Alex'. Thank you for your advice in advance....Young