http://qs1969.pair.com?node_id=219349

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

Hi Monks, I am a total novice with Perl, but I'm trying! I need to use the Win32::ODBC module on a W2K workstation, but when I try, I get a message that the module can't be located. Where should Win32::ODBC be in relation to my perl.exe? Or my script? Does 'load' mean something other than making the module available in a directory? Help!! Thanks!!

Replies are listed 'Best First'.
Re: Using Modules
by earthboundmisfit (Chaplain) on Dec 12, 2002 at 16:42 UTC
    At a command prompt, type perl -V (make sure it's a capital V)... somewhere in the out put (at the end on my W2K WS) is the contents of @INC
    @INC: C:/Perl/lib C:/Perl/site/lib .
    Modules on my WS exist in either of these two directories. To install modules on Windows, try using PPM if you have the ActiveState distro or CPAN.pm if some other.
    C:\>ppm PPM interactive shell (2.1.5) - type 'help' for available commands. PPM> install DBI Install package 'DBI?' (y/N):
    BTW, I highly recommend using the DBI module over Win32::ODBC

    ---- I am what I read

      BTW, I highly recommend using the DBI module over Win32::ODBC

      Don't forget that you'll also need DBD::ODBC as well.

      -- vek --
        A lot depends on the monk's RDBMS. I prefer a native DBD::MySQL driver to the more generic ODBC connect, but to each their own.

        snippet to list ODBC data sources:

        #! perl -w use strict; use DBI; my @driver_names = DBI->available_drivers; print join("\n",@driver_names), "\n"; my @dataSources = DBI->data_sources ("ODBC"); print join("\n-",@dataSources);
        ---- I am what I read
      I downloaded the DBI module and used WINPKZIP to extract it into a folder in my perl dir. Now what? I seem to have PPM installed, but I can't find a ppd file for DBI. The docs say to copy the module into my perl directory, but I'm not sure what to copy to where. Man, I feel dumb!! Thanks for you help.
        RTFM ;-)

        You can browse the repositories and use set to tell PPM to look in the one you know has the module you want. Type help set at the PPM shell to learn about this.

        ---- I am what I read

Re: Using Modules
by John M. Dlugosz (Monsignor) on Dec 12, 2002 at 16:31 UTC
    You need to download and install that module on your machine. Read up on "PPM" (Perl Package Manager) in the ActiveState documentation. If you don't have trouble with proxies or whatnot, doing PPM install Win32-ODBC at a command-prompt should do the trick. The docs show how to manually download first if it can't handle that.
Re: Using Modules
by UnderMine (Friar) on Dec 12, 2002 at 16:35 UTC
    This sound like an installation issue. Win32::ODBC is a old method of using ODBC connections under perl. This is about 5 years old and predates Windows 2000 by some margin.

    I would recommend DBI and DBD::ODBC driver to generate more maintainable and portable code unless there is a particular reason for using Win32::ODBC (eg. legacy code). If you require multiple datasets from SQL Server which Win32::ODBC supported have a look at DBD::FreeTDS.

    Hope it helps
    UnderMine

Re: Using Modules
by meetraz (Hermit) on Dec 12, 2002 at 20:39 UTC
    I gave up on using ODBC on windows a very long time ago. Since DBI doesn't seem to have a MS-SQL interface, I currently use Win32::OLE and Microsoft's ADO library for all of my non-oracle database work. You can use Win32::OLE to create ADODB.Connection objects, run ADODB.Command objects, and eventually work on ADODB.RecordSet objects, just like you traditionally would in ASP or VB.