Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options


by b0dh1 (Initiate)
on May 25, 2000 at 19:31 UTC ( #14774=perlquestion: print w/replies, xml ) Need Help??
b0dh1 has asked for the wisdom of the Perl Monks concerning the following question:

I'm a perl newbie, so this could be really easy, but I just can't get it.

I've got two scripts: one that reads the data from a text file into a recordset and writes it to an Access database using an ODBC connection, and one that reads through the same db and writes out the contents of the recordset using an OLE DB connection.

What I'm trying to do is write these as one script that reads through the db, and if a field match is not found it writes the data from the textfile to the db... but it won't work.

With OLE DB I get a "not enough storage is available to complete this operation" error when trying to write to the db, and with ODBC I can't open a recordset to iterate through, "Can't locate auto/Win32/ODBC/ in @INC"

I'm running the latest build of ActivePerl on a WinNT machine. Any help would be greatly appreciated. Thanks.

Replies are listed 'Best First'.
by KM (Priest) on May 25, 2000 at 20:01 UTC
    Win32::ODBC doesn't have an execute() method (which is really what that error is telling you). Instead use the Sql() method.
    I don't know what module you are using for the 'OLE DB' (Win32::OLE?). Why aren't you just using Win32::ODBC (or DBD::ODBC) for both operations? I'm confused as to why you have textfile-&qt;DB->textfile. Why not just go textfile->textfile, or textfile->textfile->DB?


by b0dh1 (Initiate) on May 25, 2000 at 20:20 UTC

    Yes, I'm using the Win32::OLE mod. Using the Win32::ODBC mod I've been unable to open a recordset that I can iterate through. I can open a connection for executing SQL statements, but I can't open a recordset (guess I just don't know the commands for creating the recordset object)

    With the data transfer, I'm just going textfile-to-DB, but I'm looping through the recordset before each SQL INSERT statement to make sure I'm not inserting duplicate data.

      Well, as I mentioned you are trying to execute the SQL with a method that doesn't exist in Win32::ODBC. Refer to my last response (or the docs for Win32::ODBC) for the correct method. Below is a quick example of using Win32::ODBC:

      use Win32::ODBC; my $DSN = qq(DSN Name); my $db; if (!($db = new Win32::ODBC($DSN))){ print "Connection Error: " . Win32::ODBC::Error . "\n"; exit; } my $qry = qq(select * from table); if ($db->Sql($qry)){ print "SQL Error: " . $db->Error . "\n"; $db->Close; exit; } while($db->FetchRow){ my %record = $db->DataHash; print $record{FIELD}; ... etc ... } $db->Close;

      Again, read the docs that come with Win32::ODBC, and visit for more documentation.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://14774]
Approved by root
thezip switches the jolokia powder with Folgers Crystals...
[Michael W]: So i can read ok from this how do i put data back inmy @Variables = ( $Map_Request_Date, $Map_Due_Date,$Map _Cutover_Date,$Map _Complete_Date,$Ma p_Approved_Date);

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-04-27 15:31 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (509 votes). Check out past polls.