Hello Monks
I have a problem. I seem to be doing everything correct, but my info is not getting into the database. IF you notice, I put an error tracking statement print $dbh->errstr right before the executtion takes place. I tried to put this statement after the execute statemtn but it didn't execute. So the error i get is this "DBI::db=HASH(0x2305378)->errstr"
Any Ideas?? Thanks
use DBI; #database parameters my ( $data_source, $database, $user_id, $password ) =qw ( servername d +omain username password ); my $conn_string = "driver={SQL Server}; Server=$data_source; Database= +$database; UID=$user_id; PWD=$password"; #Connect the database handle. my $dbh = DBI->connect("DBI:ODBC:$conn_string") or die "$DBI::errstr\n +"; $insertSQL = <<'EndOfSQL'; INSERT INTO delivery (customerNo,salesOrderNo,sequenceNo,incrementNo,requestDate,quantity,d +eliveryDate,externalNotes,shipVia) VALUES(?,?,?,?,?,?,?,?,?) EndOfSQL my $insertHandle = $dbh->prepare($insertSQL) or die "Problem creat +ing inserting handle: ", $dbh->errstr; ########### show error ########## print "$dbh->errstr"; $insertHandle->execute('customerNo', 'salesOrderNo', 'sequenceNo', 'none', 'dateD', 'quantityD', 'dateD', 'none', 'companyD') or die "Problem Inserting: ", $dbh->errstr; #EndofSQL # Execute the query $SQL->execute() || die "Couldn't execute statement: $DBI::errstr\n"; $rowCount = $SQL->commit(); $dbh->disconnect();

In reply to Problem Inserting into Sql Server Database by peacemaker1820

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.