use Win32::ODBC; $DSN="students"; if (!($db=new Win32::ODBC($DSN))) { print "Error connecting to $DSN\n"; print "Error: " . Win32::ODBC::Error() . "\n"; } else { print "Database being searched...\n"; } $SqlStatement = "SELECT * FROM ProjectTable"; if ($db->Sql($SqlStatement)) { print "SQL failed.\n"; print "Error: " . $db->Error() . "\n"; } else { print "Inside ELSE \n"; opendir(DIR, "."); @files = readdir(DIR); closedir(DIR); shift (@files); shift (@files); while($db->FetchRow()) { undef %Data; my (%Data) = $db->DataHash(); $test = $Data{"TextField5"}; print "$test \n"; foreach $file (@files) { print "$file\n"; #<- original File Name\n"; $fileName = $file; #print "$file \n";#$file2 = $file; $file =~ s/\D//g; print "$file <- Stripped Id Number\n"; print "Should Enter If Now \n"; Open( FH, "<$fileName" ) || die "unable to open $fileName ($!)\n"; { local( $/ ); undef $/; $filecontents = ; } close( FH ); if ($test = $file) { print "Inside IF comparrison\n"; #$sqlinsert = "INSERT INTO ProjectTable (PhotoField1) VALUES ($fileName)"; $rc = $db->sql("INSERT INTO ProjectTable ('PhotoField1') VALUES ('$filecontents')"); if($rc){ die qq(SQL error "$sqlinsert": ), $db->Error(), qq(
) ; } else {print "insert success!";}} print "$test <- supposed to be new data\n"; } } } $db->Close(); exit;