Your almost there but, there is a problem with your SQL statement (it is not valid). The statement should be something like:
my $sqlstatement=("UPDATE servers SET nicl_driver_version = '$driver'
+WHERE '$field1' = '$servlist'");
So you need to put single quotes around
$driver as it is not all numeric, nor the SQL keyword NULL, I have also changed you
WHERE clause to reflect what I think you want it to do.
One good resource for SQL syntax is
w3schoolsyou also don't appear to be using $field2 or $vals for anything, and don't need the use Win32::ODBC; line for anything as well (you are not using that module in your code at all).
One last thing is that you might want to prepare your SQL statement outside your loop, and then execute it on the inside, so you don't have to prepare the same statement time and time again unnecessarily). So your code might look something like this(untested):
use DBI;
use strict;
my $DSN='Database';
my $field1 = 'Server';
my $dbh=DBI->connect("dbi:ODBC:$DSN", "admin", "")
or die "$DBI::errstr\n";
my $sth = $dbh->prepare(
"UPDATE Servers
SET nic1_driver_version= ?
WHERE '$field1' = ?" );
#Open file for reading
open(INPUT,"file.txt") || die;
while (<INPUT>) {
chomp;
my ($servlist, $driver)=split(/,/);
$sth->execute($driver,$servlist) or die;
}
close (INPUT);
$dbh->disconnect;
update:added line to script because I neglected to initialize
$field1 (so that line is now there), which would be the reason for the failure,
p01p0t was having in
Re: Re: Re: Re: Updating Specific Fields in MS Access
-enlil