#!/perl/bin/perl -w use DBI; use Win32::ODBC; use User::pwent; # Global Variables my @statement; # Array of sql statements that will be used for Access my @row; # Array of table rows read from MySql my @message; # Array of error messages used for debugging Access # MySQL Connection my $dbh = DBI->connect('DBI:mysql:DBName:localhost', 'UserName', 'Password', { RaiseError => 1, AutoCommit => 1 }); # Access Connection my $connection=new Win32::ODBC("DSN=;UID=;PWD=;"); unless ($connection) { push @message,"Unable to connect to database!"; } push @message,$connection->Error; # Create the sql statement for MySql and execute it $sth = $dbh->prepare("SELECT url,title,keywords from addresses"); $sth->execute; while ((@row) = $sth->fetchrow_array) { # This is were we grab all the table rows from MySql and store them into # an array to be inserted into Access. push @statement,"INSERT INTO keywords (url, title, keywords) VALUES ('$row[0]', '$row[1]', '$row[2]')"; } # Execute sql statments and if there is an error report it foreach (@statement){ $connection->Sql($_); if ($connection->Error()){ print "\nERROR: \nThe SQL statement:\n $_ \n\ncaused the error:\n\n ",$connection->Error(); die(); } push @message,$connection->Error(); } # Close the Access DB Connection $connection->Close(); # Close the MySql DB connection $sth->finish; $dbh->disconnect;