
Jasmine
Administrator
/ Moderator
Jul 30, 2002, 10:37 PM
Post #2 of 2
(1588 views)
|
That's not much information to figure out what you want, but if you're referring to working with Perl and Access, you can use DBI. (Docs are here). You can also use Win32::DBIODBC, which is a"very basic very alpha quality Win32::ODBC emulation for the DBI". You'll need to set up your Access db as an ODBC source, so here's some info I posted to perlmonks.org some time ago about setting up an Access db as an odbc source so perl can use it. The sample code uses Win32::ODBC module. You can apply the part about setting up your Access db as an ODBC source to any method you choose (DBI, Win32::DBIODBC or Win32::ODBC). You don't need to connect directly with an Access database because Access is an ODBC source. Set up ODBC (if needed), then add the specific database to the ODBC source. To do this, go to your control panel and click ODBC Data Sources. Under the User DSN tab, you should see something like "MS Access 2000 Database" and on the same line, "Microsoft Access Driver". If you do, you're good. If you don't, you'll need to install the additional ODBC drivers from your Win2k cd. After you've confirmed that that the Access Driver is installed, click "Add" (in the User DSN window), select the Access Driver, then click Finish. Now you're at the setup window. Enter a mnemonic data source name, a short description, then click "Select" and browse to the Access db. If the db is password protected, click Advanced and enter the u/p. At this point the db is registered as an ODBC source. In your program, use Win32::ODBC and from there, it's straight SQL statements to insert, delete, query, etc.. Docs for Win32::ODBC are at http://search.cpan.org/doc/GSAR/libwin32-0.16/ODBC/ODBC.pm. Here's some sample code: use Win32::ODBC; my $db = Win32::ODBC->new('datasourcename'); # as defined in your ODBC panel $db->Sql( "INSERT INTO tablename ( Field ) VALUES( 'text to insert' ) ); $db->Close(); Win32::ODBC is part of the libwin32 libraries, so if ActivePerl is installed, it ought to be installed correctly already. But you may want to install a more current version if available, which you can do by using the ppm manager (ppm.bat in your perl directory) and typing install libwin32 at the prompt.
Hope this helps get you started. If this isn't what you were asking, please elaborate
|