Hello Simon (and group),

I'm still having a problem with creating the Access database using OLE and wondered if 
you might have some insight.

The following code snippet

$obj = Win32::OLE->new('Access.Application','Quit');
print "connected to Access...\n"; $obj->NewCurrentDatabase($someDB);
print "created database $someDB\n";
$obj->Quit();

Produces this error

Win32::OLE(0.1501) error 0x80010108: "The object invoked has disconnected from its 
clients"
   in METHOD/PROPERTYGET "Quit" at somescript.pl line 0

There is a process called MSACCESS still running and the database isn't accessible 
from client PCs until I kill this process, I get a message stating that the database 
is currently in use by another session.

The application I'm writing is a very simple script running on the server in a telnet 
session.  It checks for the prior existence of the database and deletes it if found.  
It then collects data from a number of flat-file, bar-separated tables and record 
layouts and attempts to create the Access database.  Haven't even gotten that far yet. 
 I'm just trying to open the Access object, create the database and close the object.

Does anyone have experience with this error in Win32::OLE when working with Access?

Glen


> -----Original Message-----
> From: Simon Oliver [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, February 07, 2002 10:55 AM
> To: Moulder, Glen
> Cc: [EMAIL PROTECTED]
> Subject: Re: FW: Create database
> 
> 
> Here's are a couple of scripts I had hanging around.  The 
> first uses OLE the second uses Win32::ODBC to do the job.
> 
> --
>   Simon Oliver
> 
> use warnings;
> use strict;
> use Win32::OLE;
> 
> my $file="c:/test.mdb";
> 
> die "File '$file' already exists!\n" if (-e $file);
> 
> my $access = Win32::OLE->new('Access.Application');
> $access->NewCurrentDatabase($file);
> $access->Quit();
> 
> print -e $file ? "Ok" : "Error";
> 
> 
> 
> use warnings;
> use strict;
> use Win32::ODBC;
> 
> my $option = ODBC_ADD_SYS_DSN;
> my $driver = 'Microsoft Access Driver (*.mdb)';
> my $dsn = 'Test_DSN';
> my $dbf = 'd:\temp\test.mdb';
> 
> my $conn = new Win32::ODBC()
>   or print "Error creating ODBC object";
> 
> Win32::ODBC::ConfigDSN ( $option, $driver, 'DSN=$dsn', 
> 'CREAT_DB=$dbf' ) 
>   or print "Error creating DSN '$dsn'.\n";
> 
> print Win32::ODBC::Error();
> 
> $conn = new Win32::ODBC($dsn) 
>   or print "Error opening DSN '$dsn'.\n";
> 
> print Win32::ODBC::Error();
> 
> my $sql = 'CREATE TABLE test_table (id int, name varchar(32))';
> 
> my $rv = $conn->Sql($sql);
> warn $rv;
> 
> my @tables = $conn->TableList('','','','');
> 
> print join(',', @tables), "\n";
> 
> $conn->Close;
> 

Reply via email to