in reply to Re: Question about joins?
in thread Question about joins?

excellent :) thanks here is the code.
$username="admin"; $pw="temppwd"; # connect to the named DSN, returns a database handle $dbh=new Win32::ODBC("DSN=APS;UID=$username;PWD=$pw;"); die "Unable to connect to DSN PerlSysAdm:" . Win32::ODBC::Error( ) . +"\n" unless (defined $dbh); $selst = "select APSVehicles.*, DlrLogins.* FROM APSVehicles INNER JOI +N DlrLogins ON APSVehicles.Dealer = DlrLogins.P1 or APSVehicles.Deale +r = DlrLogins.P2 WHERE DlrLogins.UserID = '$AuthUser' ORDER by DLRID" +; print "<BR>$selst<BR>\n"; $rc = $dbh->Sql($selst); die "Error: " . Win32::ODBC::Error( ) . "\n"; $results = $dbh->RowCount( ); $a = 1; $temp = 0; while ($dbh->FetchRow( )) { push(@AutoActive,$dbh->Data("AutoActive")); push(@Tag,$dbh->Data("Tag")); push(@Dealer,$dbh->Data("Dealer")); push(@YrMade,$dbh->Data("YrMade")); push(@Make,$dbh->Data("Make")); push(@Model,$dbh->Data("Model")); push(@ExtCol,$dbh->Data("ExtCol")); push(@Price,$dbh->Data("Price")); push(@DateAdded,$dbh->Data("DateAdded")); push(@FinanceAvail,$dbh->Data("FinanceAvail")); $a = ++$a; } $dbh->DropCursor( ); $dbh->Close( );
Thanks - Zack

Replies are listed 'Best First'.
Re^3: Question about joins?
by Grygonos (Chaplain) on Jan 14, 2005 at 19:32 UTC
    I would reccomend an on the fly connect, in order to reduce dependence on the DSN being setup.
    my $dbh = DBI->connect('dbi:ODBC:driver=SQL Server;server=192.168.x.x; +database=My Database;app=my database application',$user,$pass);