Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help/Advice needed to install DBI.pm module 1

Status
Not open for further replies.

Evan145

Technical User
Dec 24, 2001
33
0
0
IE
Hi,
Still learning Perl and need help/advice in installing DBI.pm

I have Win98 SE and am running ActivePerl. I recently came across a sample script that accesses an Access Database and creates a simpe table.
But the script fails because DBI.pm cannot be found.
I did a search in both /lib and /site/lib and I cant find it, only finds DB.pm.

How do I go about adding a new module?
Can anyone tell me where/IF exactly I can get DBI.pm and HOW/WHAT to do to install it. Basiclly, Im afraid to mess up my PC.

These are the responses when I run perl -v and perl -V....if they help.

Thanks
Evan

*******************************************************
perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 633 provided by ActiveState Corp.

perl -V
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
Locally applied patches:
ActivePerl Build 633
Built under MSWin32
Compiled at Jun 17 2003 21:33:05
@INC:
C:/Perl/lib
C:/Perl/site/lib
 
try to use PPM, is your machine connect to internet?
if yes just go to your command prompt then type PPM
your can search for it

PPM> search DBI

if you want to install just type

PPM> install DBI <number>

 
Thank you papanick,
that was a great help,(will definitely remember that).

The DBI.pm installed fine.

You been a great help.....with simple and straight-forward advice.

But, can you tell me whats wrong with this script now?
error
<H1>Software error:</H1>
<PRE>Can't find string terminator &quot;(EndOfSQL)&quot; anywhere before EOF at
dBAccess.pl line 27.
</PRE>


Must the database exist?...Must I create an ODBC connection?

Code:
#!/usr/bin/perl -w
    ###################################################
    ## This is a simple script that will create a 
    ## new table in a Access Database. This is to show
    ## how to connect to an Access Database thru Perl
    ## by using DBI and the ADO driver. You can also
    ## connect by using ODBC, by replacing where you 
    ## ADO. dbi:ADO:$DSN
    ###################################################
    use POSIX;
    use strict;
    use CGI qw(:standard);
    use CGI::Carp qw(fatalsToBrowser);
    use DBI;
    use Time::Local;
    print header; 
    	
    ######################################
    ## Set DSN-Less Connection
    ######################################
    my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=CC:\MyPerl\Exercises\perl.mdb';
    my $dbh = DBI->connect(&quot;dbi:ADO:$DSN&quot;, '','') 
    	or die &quot;$DBI::errstr\n&quot;; 
    		
    ######################################
    ## Generate the SQL Statement
    ######################################
    my $sql = <<&quot;EndOfSQL&quot;;
    CREATE TABLE tblContacts2 (
    	ID				COUNTER,
    	LastName		CHAR(40),
    	FirstName	CHAR(40),
    	MiddleName CHAR(20);
    	HomePhone	CHAR(40),
    	WorkPhone	CHAR(40),
    	CellPhone CHAR(40);
    	BirthDay CHAR(20);
    	Fax			CHAR(40),
    	Email			CHAR(40),
    	Address1		CHAR(40),
    	Address2		CHAR(40),
    	City			CHAR(30),
    	State			CHAR(10),
    	ZipCode		CHAR(20),
    CONSTRAINT ID_PK PRIMARY KEY(ID)	
    )
    EndOfSQL
    	
    	
    ################################
    ## Execute the SQL Statement
    ################################
    $dbh->do($sql) 
    	or die &quot;Execution problem: $DBI::errstr&quot;;
    print &quot;Table was Created&quot;;
    	
    ######################################
    ## Close the connection when finished:
    ######################################
    $dbh->disconnect;

Evan
 
Why do you have semicolons after MiddleName Char(20)
(also for CellPhone and BirthDay)

RajD
 
Hi me again,
After fixing some stupid syntax errors in the script, which Rajd correctly spotted...I changed it to..

Code:
my $sql = qq{ CREATE TABLE tblContacts2 (
        ID                COUNTER,
        LastName        CHAR(40),
        FirstName    CHAR(40),
        MiddleName CHAR(20),
        HomePhone    CHAR(40),
        WorkPhone    CHAR(40),
        CellPhone CHAR(40),
        BirthDay CHAR(20),
        Fax            CHAR(40),
        Email            CHAR(40),
        Address1        CHAR(40),
        Address2        CHAR(40),
        City            CHAR(30),
        State            CHAR(10),
        ZipCode        CHAR(20),
    CONSTRAINT ID_PK PRIMARY KEY(ID)    
    )};

But now my latest error is...


<H1>Software error:</H1>
<PRE>install_driver(ADO) failed: Can't locate DBD/ADO.pm in @INC (@INC contains:
C:/Perl/lib C:/Perl/site/lib .) at (eval 7) line 3.
Perhaps the DBD::ADO perl module hasn't been fully installed,
or perhaps the capitalisation of 'ADO' isn't right.
Available drivers: ExampleP, ODBC, Proxy.


I tried the PPM search again for DBD::ADO and other variations of ADO....tried it again by installing Win32::ADO

Why didnt PPM find a DBD::ADO module? Im lost here!!!!

Evan
 
Well......well......well.......
After a bit of surfing and research on Tek-Tips I discovered I was going about it all wrong. ADO seems tricky so I reverted to ODBC ....I created a DataSource myTest

then changed the DBI->connect line to
Code:
my $dbh = DBI->connect(&quot;dbi:ODBC:myTest&quot;, '','') or die &quot;$DBI::errstr\n&quot;;

and violá


C:\MyPerl\Exercises>perl dbAccess.pl
Content-Type: text/html; charset=ISO-8859-1
Table was Created
C:\MyPerl\Exercises>


My first experiment in Perl and Database is a success.
Thanks to papanick and RajD
 
Hello Evan
I read your questions well I have also started programming in Perl with Oracle 8i and I also did have some problems installing DBI and DBD modules as We have a proxy and in spite of prxy address in environment tabs , I had not been able to install but I did succed when I stored to modules on to my hard disk and then extracted from theer and now Im doing well with perl, XML and Oracle 8i
May be we could exchange our views , let me know what your developing with your Perl
Regards
Ronan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top