Your response is appreciated.
When I try to place the prepare before the loop, it complains about uninitialized values.
I tried using placeholders, to no avail, so I kept the prepare in the loop. Now I have:
#! C:\perl\bin\perl.exe -w
use DBI;
#use strict;
my $DSN='Database';
my $driver;
my $servlist;
my $field='Server';
#connect to database
my $dbh=DBI->connect("dbi:ODBC:$DSN", "admin", "") || die;
#Open file for reading
open(INPUT,"file.txt") || die;
while (<INPUT>)
{
chomp;
my ($servlist, $driver)=split(/,/);
my $sqlstatement=("UPDATE Servers SET nic1_driver_version='$driver
+' WHERE '$field' = '$servlist\n'");
my $sth=$dbh->prepare($sqlstatement);
$sth->execute || die;
}
close (INPUT);
$dbh->disconnect;
Spits back:
DBD::ODBC::st execute failed:
MicrosoftODBC Microsoft Access Driver Too few parameters. Expected 1. (SQL-07002)(DBD: st_execute/SQLExecute err=-1) at C:\Perl\scripts\test\newer.pl line 22, <INPUT>
line 1.
Died at C:\Perl\scripts\test\newer.pl line 22, <INPUT> line 1.
I am confused about the parameters error.
Regards,
jw
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.