in reply to How can I create Access tables with Perl?

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

Replies are listed 'Best First'.
Re: Re: How can I create Access tables with Perl?
by luoina (Acolyte) on Feb 18, 2004 at 05:16 UTC
    Thank you very much!!! I will try it... Young
Re: Re: How can I create Access tables with Perl?
by luoina (Acolyte) on Feb 18, 2004 at 23:23 UTC
    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