The code and error/problem-information you provided are insufficient to help you. to me at least $harga = 0, $harga2 = kan.$harga; doesn't make any sense, and perl doesn't like it that much either:

[1046]tom@margo scripts $ perl -we '$harga = 0, $harga2 = kan.$harga;' Unquoted string "kan" may clash with future reserved word at -e line 1 +.
so I can't help you with your problem, as the SQL itself looks fine:
[1052]tom@margo scripts $ sqlite /home/tom/sqlitetest.sldb SQLite version 2.8.14 Enter ".help" for instructions sqlite> create table barangan (NamaBarang text NOT NULL, CompanyID int +(9)); sqlite> insert into barangan (NamaBarang, CompanyID) VALUES ('hello', +1); sqlite> insert into barangan (NamaBarang, CompanyID) VALUES ('hello2', + 2); sqlite> SELECT rowid, NamaBarang ...> FROM barangan ...> WHERE CompanyID = '2' ...> ORDER by rowid ASC ; 2|hello2

2 more notes to make your job easier in the future:

1. Always check for the return-value of anything that can produce errors and indicates errors via the return-value, including $dbh->prepare(), as ysth already said.

2. Don't interpolate data into SQL when not technically necessary (e.g. dynamically inserting the tablename):
instead of

$sqlstatement2 =qq~ SELECT rowid, NamaBarang FROM barangan WHERE CompanyID = '$companyid' ORDER by rowid ASC ~;
write
$sqlstatement2 =qq~ SELECT rowid, NamaBarang FROM barangan WHERE CompanyID = ? ORDER by rowid ASC ~;
and give $companyid as a parameter to $sth2->excute() (as in $sth2->excute($companyid)), or use $dbh->quote() before you interpolate:
my $quotedCID = $dbh->quote($companyid); $sqlstatement2 =qq~ SELECT rowid, NamaBarang FROM barangan WHERE CompanyID = '$quotedCID' ORDER by rowid ASC ~;
To adopt the practice of using placeholders if you use SQL in any language you programm in, greatly increases the quality and security of your code.

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus


In reply to Re: Converting from MySQL to SQLite by Tomte
in thread Converting from MySQL to SQLite 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.