Hi,

I'm not trying to connect to the 2 db's at the same time, so I'm not sure
what you mean.

What I'm doing is executing the script for the 1st; editing it so that
the "dbname" parameter in the connect string is for the other 2nd; running
the script again.

The problem is that it's only connecting to whichever is the default db
every time.

Bilal

On Thu, 11 Sep 2003, Martin J. Evans wrote:

> I haven't tried it in a long time (other than running make test) but from
> perldoc DBD::ODBC:
> 
>        odbc_async_exec
>            Allow asynchronous execution of queries.  Right now,
>            this causes a spin-loop (with a small "sleep") until
>            the sql is complete.  This is useful, however, if you
>            want the error handling and asynchronous messages (see
>            the err_handler) below.  See t/20SQLServer.t for an
>            example of this.
> Martin
> -- 
> Martin J. Evans
> Easysoft Ltd, UK
> Development
> 
> On 11-Sep-2003 [EMAIL PROTECTED] wrote:
> > Hi, 
> > 
> > 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: 
> > 
> > $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 
> 
> 

Reply via email to