ActiveState Powered by ActiveState

ActiveState Community


Database Updates etc with DBI

Posted by maldrac on 2008-03-06 03:14

Hi

I am using the following code to read data from a local database, I also want to be able to write to the database, but can't find any code examples on the internet that work with my current setup, for reasons I would like to only use the DBI module and as such things like DBI->connect('string') and sth->execute('string') don't work with what I have. So, are the commands like InsertRow that match the command set which contains Connection() and FetchRow()?

#!C:\Perl\bin\perl.exe -w
use strict;
use CGI ':standard';
use DBI;

#Set up variables
my $dbName = "testDB";
my($i, $j, $id, $bg, $data, $SQL);

#Make a connection to the database
use Win32::ODBC;
$data = new Win32::ODBC($dbName);
$data->Connection();

#Initialise output and HTML tags
print "Content-type:text/html\n\n";
print <<"htmlHeader";
htmlHeader

#Output the data
while($data->FetchRow()){
   my @rowValues=$data->Data;
   print "$rowValues[1] $rowValues[2] $rowValues[3]";
}

#Output the HTML end tags
print <<"htmlFooter";
htmlFooter

-->