in reply to Loop Question

Are you sure this is the query you're running against Access? Is it possible that you've dropped some quotes along the way? I strongly suspect that     WHERE CustomerNumber = $CustomerNumber should probably read     WHERE CustomerNumber = '" . $CustomerNumber . "' ... (though you'll need to protect against someone entering a ' in the CustomerNumber field), and     AND #TransType = P"); should read     AND #TransType = 'P'); And check return codes! $db->Sql() may be leaving valuable information around that you're ignoring.

Replies are listed 'Best First'.
Re: Re: Loop Question
by davorg (Chancellor) on Mar 21, 2001 at 22:16 UTC
    " ... WHERE CustomerNumber = '" . $CustomerNumber . "' ... "

    Why isn't that just:

    " ... WHERE CustomerNumber = '$CustomerNumber' ... "
    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: Re: Loop Question
by Anonymous Monk on Mar 21, 2001 at 22:16 UTC
    From your suggestion, this is what i printed:
    $Sql="SELECT * FROM Cust_act_da WHERE CustomerNumber = $CustomerNumber + AND TransType = 'P'"; print $Sql; $db->SQL( $sql );
    and I get this when SQL is printed: "SELECT * FROM Cust_act_da WHERE CustomerNumber = 13 AND TransType = 'P' " This is what I have in my code:
    while ($CustomerNumber = $Data{"CustomerNumber"}) { $db->Sql("SELECT * FROM Cust_act_da WHERE CustomerNumber = $C +ustomerNumber AND TransType = 'P'");
Re: Re: Loop Question
by dws (Chancellor) on Mar 21, 2001 at 23:25 UTC
    I jumped the gun on this. If you can guarantee that $CustomerNumber will only hold digits, and CustomerNumber is a numeric field in the database, then don't quote it in the query.