Hi, Thanks, "use dbA" works. It doesn't work as part of a do statement (i.e. $dbh- >do("use dbA")), but it looks like it's working when I prep and execute "use dbA" using a statement handle.
I'm using DBD::Sybase v1.01, so I guess there's still an issue with DBI only connecting to the default db. I've cc'd dbi-dev since they might like to know about this bug. Thanks and take care, Bilal Quoting Chuck Fox <[EMAIL PROTECTED]>: > Bilal, > > Try just executing "use dbA" after the connection is made. Another > option is to directly reference the db in the query by using "select * > from dbA.dbo.array". A table can be referenced as tableName or > ownerName.tableName or as databaseName.ownerName.tableName. Insofar as > the bug, try ugrading to the latest dbd, I believe that 1.01 was just > released. We are using 1.0 and the issue with the db disappeared > there. I think the fix was in the 0.94 release. > > Chuck > > [EMAIL PROTECTED] wrote: > > >Hi, > > > >Do you mean replace "dbname=dbA" with "dbname=dbB" in my connect string? > >I've tried that. Is there another way to switch the data source to > >another db? > > > >Is there any fix for this DBD::Sybase bug? > > > >Thanks, > >Bilal > > > > > >On Thu, 11 Sep 2003, Chuck Fox wrote: > > > > > > > >>[EMAIL PROTECTED] wrote: > >> > >> > >> > >>>Hi, > >>> > >>> > >>> > >>> > >>Hello, > >> > >> > >> > >>>I'm trying to connect to two ms sqlserver 2000 databases with the same > schema > >>>(let's call them > >>>dbA and dbB) using the following code: > >>> > >>>my $connect_string = "dbi:Sybase:dbname=dbA:server=MyServer"; > >>>$connect_string .= ";host=192.168.0.2;port=1433"; > >>> > >>>my $dbh = DBI->connect($connect_string, $username, $userpass, {PrintError > => > >>>0}); > >>>die "Unable for connect to server $DBI::errstr" > >>> unless $dbh; > >>> > >>>and in my freetds.conf I have: > >>> > >>>[MyServer] > >>> host = 192.168.0.2 > >>> port = 1433 > >>> tds version = 4.2 > >>> try domain login = no > >>> try server login = yes > >>> > >>> > >>>I have read access to both dbA and dbB. However if dbB is my default db > and I > >>>specify dbA as the dbname (as in the example above), or vice versa, when > my > >>>script executes the following: > >>> > >>> > >>> > >>> > >>Why not just "use dbB" or whichever is appropriate to the query ? I > >>seem to remember some bug in Sybase DBD that prevented it from > >>using/processing the database specified in the connect string. > >> > >> > >> > >>>$sth = $dbh->prepare("select count(*) from array"); > >>>die "Unable for connect to server $DBI::errstr" unless $sth; > >>>if($sth->execute) { > >>> while(my @dat = $sth->fetchrow) { > >>> print "@dat\n"; > >>> } > >>>} > >>> > >>>the data is retrieved from the default db rather than the one I specified > (btw, > >>>yes, i know for sure that the "select count(*) from array" on both db's > should > >>>return different numbers). So I think that DBI's only connecting to the > > >>>default db. > >>> > >>>As well, the statment > >>> > >>>print "Data sources: " . ($dbh->data_sources()) . "\n $DBI::errstr\n"; > >>> > >>>prints out no data sources. > >>> > >>>The DBD I'm using is DBD::Sybase running on the freetds library. My > script's > >>>running on a linux box and the sqlserver 2000 db's are on a windows 2000 > adv > >>>server box. > >>> > >>>So any ideas on how I may get around this problem? I would really > appreciate > >>>any help. > >>> > >>>Thanks, > >>>Take care, > >>>Bilal > >>> > >>> > >>> > >>HTH, > >> > >>Chuck Fox > >>Principal DBA > >>America Online, INC > >> > >> > >> > >> > > > > > > >