You have some scoping issues. In your if blocks, you declare $FilmName and $Price with my. That makes each scoped to that block only. When you refer to $FilmName and $Price later, they will be different global varibles. Because you haven't declared them and are using strict, your script will die with a message like:
Global symbol "$FilmName" requires explicit package name at FILE line +LINE
I'm guessing you haven't checked your error log. (Update: or this isn't actually very close to the actual code you are using.)

I also notice here:

my $sth = $dbh->do( "INSERT INTO tblFilm (Name, Price) VALUES ('$FilmName', '$Price')") || + print "Can't prepare statement: $DBI::errstr";
that you probably want to use "or" instead of "||". Since || has higher precedence than =, the way it is will assign the return value of do() to $sth, or assign 1 (the return value of print) if do() returned false. With or instead of ||, $sth will be left undefined if the do() fails.

In reply to Re: Insert into MSSQL by ysth
in thread Insert into MSSQL by Anonymous Monk

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.