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

I can connect to an Access 2000 database on my info server and now I want to close/quit the database if it is open. Please advise because my attempt doesnt close the database and nothing happens except it says it connected to database.
use strict; use warnings; use Win32::ODBC; use Win32::OLE; use Win32::OLE::Const 'Microsoft DAO'; my $db = "\\\\myinfoserver\\myaccess2000.mdb"; my $dsn = "tes"; $db = new Win32::ODBC($dsn) || die "Cant open: $!"; print "Connecting to database source $dsn\n"; $db->Close(); exit;

Replies are listed 'Best First'.
Re: Close Access db using Perl
by shmem (Chancellor) on Nov 02, 2006 at 19:43 UTC
    It seems that you're not closing the database, but the handle you got opening that database. If you want the database to be closed in the sense that there's no connection to it, you must tell the piece of software that handles the connections / monitors the database to close the connections, invalidate the handles and mark the database as closed.

    That's somewhat nebulous, as I really seldom have to do anything w/windows...

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Close Access db using Perl
by GrandFather (Saint) on Nov 02, 2006 at 19:36 UTC

    I use $dh->disconnect (). I've never checked to see that anything much happens though.

    Update: the DBI documentation says:

    Disconnects the database from the database handle. disconnect is typically only used before exiting the program. The handle is of little use after disconnecting.

    DWIM is Perl's answer to Gödel
      Umm, the OP isn't using DBI
Re: Close Access db using Perl
by astroboy (Chaplain) on Nov 03, 2006 at 13:37 UTC