Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Can't locate DBD/ODBC.pm in @INC

by Fian (Novice)
on Mar 15, 2001 at 17:58 UTC ( #64667=perlquestion: print w/ replies, xml ) Need Help??
Fian has asked for the wisdom of the Perl Monks concerning the following question:

I managed to download the DBD/I or whatever and I now am getting the following error
install_driver(ODBC) failed: Can't locate DBD/ODBC.pm in @inc (@inc contains: c:\BIN\perl\lib c:\BIN\perl\site\lib .) at (eval 6) li +ne 3, perhaps the DBD::ODBC perl module has'nt been fully installed, or perhaps the capitalisation of`ODBC' isn't right. Available drivers: ADO, ExampleP, Multiplex, Proxy. at shc_details_vON +E.pl line 126 c:\perl_scripts>
Help. TOTALLY lost here....

Comment on Can't locate DBD/ODBC.pm in @INC
Download Code
(ar0n) Re: Can't locate DBD/ODBC.pm in @INC
by ar0n (Priest) on Mar 15, 2001 at 18:10 UTC
    Try searching for ODBC.pm (Start -> Find -> Files or Folder).

    Right now you're being a bit vague.

    [ar0n]

Re: Can't locate DBD/ODBC.pm in @INC
by Jouke (Curate) on Mar 15, 2001 at 18:15 UTC
    Maybe I'm being too obvious, but simply downloading does not do the trick. I can't read in your posting how you installed DBD::ODBC, but if you're using ActivePerl on Win32 (which I presume), I suggest you use PPM to install modules.

    Jouke Visser, Perl 'Adept'
Re: Can't locate DBD/ODBC.pm in @INC
by frankus (Priest) on Mar 15, 2001 at 18:22 UTC
    1. Initially, as has been said: use your operating system to confirm that the file does exist in the directories specified in @INC
    2. write more by way of explanation of what you've done subsequent to downloading the module, otherwise a lot of well meaning monks'll be telling you stuff you may already know. Which is a waste of everyone's time :)

    --
    
    Brother Frankus.
      OK.
      ODBC is in the directories specified in @INC.
      PPM did'nt download and install DBI so I downloaded DBI.zip from www.activestate.com After unzipping it I read the readme which said:
      "To install this ActiveState PPM package, run the following command in the current directory: ppm install DBI.ppd
      This I did and it replied with
      writing c:\BIN\perl\site\lib\auto\DBI\.packlist
      And that was it. I get the error that I wrote about before when I try to run the script.


      Tell you what. Could someone direct me to a site that offers tutorials on how to use Perl to access a database. Preferably an MS Access database

      Thank you..

        Tell you what. I'll actually address the problem you're describing, rather than blowing you off. and as for DBI tutorials, you're soaking in them!

        You're only getting half of what you need. DBI is the "Database Interface" half. The part I think you're missing (based on the error messages you report, and the process you've described) is the DBD -- "Database Driver". Look on PPM or CPAN for DBI::ODBC.

        See, much like ODBC, DBI only describes a common set of methods for accessing data stores. You need download the drivers which actually implement those methods. As always, CPAN has your hookup
        Once you've got that installed, you can use

        $dbh = DBI->connect('dbi:ODBC:DSN', 'user', 'password') || die ("Can't + connect to database : ",$DBI::errstr);
        to connect to your database. You may need to alter the dbi:ODBC:DSN portion depending on how your database is set up.
        Also note the $DBI::errstr; when debugging database problems, this variable is your best friend -- it'll report database errors, not perl errors, like $! and $@ do.
        once the connection's made and the $dbh is live, you can start preparing SQL :
        $sql = $dbh->prepare ("SELECT field FROM table") or die ("Unable t +o prepare statement: ",$DBI::errstr);
        Again, notice the die. If this statement dies, there's typically a problem with the statement's syntax, or the database handle ($dbh) is undefined.

        This is where the fun happens :

        $sql->execute()or die ("Unable to execute get_servertime : ",$DBI: +:errstr);
        This will set the SQL gnomes scurrying, and stores the result of the statement in $sql.

        Now that the results are in, how to read them? It depends. There's several methods of doing so, and each one is detailed in the documentation. My most often used one is

        @l_row = $sql->fetchrow_array;
        , but there's other methods of doing so. There's a nice hash method which'll store the field names as the hash keys, so you can manipulate$row{fieldname} if that's clearer than working with array elements.

        When everything's done and said,

        $dbh->disconnect
        to close the database. For further information, see Programming the Perl DBI, and of course, DBI's own POD, which has a synopsis of how to connect and read to a database.

        OK?

Re: Can't locate DBD/ODBC.pm in @INC
by tame1 (Pilgrim) on Mar 15, 2001 at 20:03 UTC
    Looks like you have installed the DBI.pm right, but not the DBD you need. Go to the DBD directory on CPAN and get the latest ODBC driver file.

    Remember, DBI is the engine, the DBDs are the drivers. Gotta have a Chevy driver for the Chevy car ;-)

    What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"
      Some straight questions now

      When I download the ODBC from CPAN and I then have to unzip the file, do I have to extract these files to the sam edirectory as my Perl source code?

      If I don't then does it matter where I save it (I have a sneaking suspicion that it does)

      I have already downloaded the ODBC and it is where it is supposed to be but I still get that error that it can't locate it:



       Can't locate DBD/ODBC.pm in @INC

        Did you unzip and untar the package, and do the installation procedure outlined in the INSTALL file? ( typically perl Makefile.PL; make; make install?

        When you say the file is where it is supposed to be, there must be a ODBC.pm file in the DBD subdirectory of one of the @INC directories. Are you sure that's correct?

        Philosophy can be made out of anything. Or less -- Jerry A. Fodor

        What is your OS? you downloaded a zip file? or was it a tar.gz file? For linux, etc. you use tar -xvzf filename to open the file.
        Then you should do this:

        perl Makefile.PL make make test make install

        in that order. If you are on Windows, I guess use the ppm system. I am not familiar enough with windows perl to help with that.

        What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://64667]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2014-07-30 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls