
PapaGeek
User
Feb 24, 2014, 11:42 AM
Views: 37449
|
Re: [FishMonger] Windows 7, MS Access 2013, DBI question
|
|
|
I managed to get MS Access working with Perl on Window7. As a background: Perl –ver gives me: This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-thread … etc. I’m running Strawberry Perl. C:\Program Files\Microsoft Office 15\root\office15>notepad msaccess.exe.manifest Shows the line: <assemblyIdentity processorArchitecture="X86" type="win32" name="msaccess" version="15.0.0.0"> And the “computer icon” properties page shows: Windows 7 professional System type: 64-bit Operating System So, it looks like I’m running 32 bit Perl and 32 bit Access on a 64 bit operating system! I couldn’t get ODBC to work in the control panel so I searched the web and found the trick of saving my database as mdb 2010 compatible and running the 32 bit version of the control panel ODBC to create an ODBC named “Funds”. Still not sure how to work with the new native .accdb files. c:\windows\sysWOW64\odbcad32.exe And I managed to read my first database records into Perl with the following code:
use Modern::Perl '2013'; use DBI; my $dbh = DBI->connect('dbi:ODBC:Funds', '', '', { RaiseError => 1, odbc_cursortype => 2}); my $sth = $dbh->prepare("SELECT * from Accounts"); $sth->execute; my @row; while (@row = $sth->fetchrow_array) { print join(", ", @row); print "\n"; } And it returned
2, Sandy 401K, Finiti, 2004-01-05 00:00:00 3, Shirley 401K, Regional, 2011-07-09 00:00:00 I’m probably not going to use * as a selection criteria, but is there a way to determine what fields were returned in what order? It looks like all fields are returned as strings. What is the best way to cast each field into its proper data type? In my case: number, string, string, date
(This post was edited by PapaGeek on Feb 25, 2014, 4:29 AM)
|