Thread DBD::Sybase default Datenbank angeben (7 answers)
Opened by xDxD at 2010-01-28 16:07

xDxD
 2010-01-28 19:42
#131446 #131446
User since
2008-12-08
19 Artikel
BenutzerIn
[default_avatar]
Habe den Code jetzt etwas abgeändert.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use strict;
use warnings;
use DBI;

my $dsn = 'DBI:Sybase:host=myhost;port=1433;database=mydb';


my $dbh = DBI->connect($dsn, "user", 'pass');
die "unable to connect to server $DBI::errstr" unless $dbh;

$dbh->do("use mydb") or die "couldn't change database";

my $query = "SELECT * FROM Session";
my $sth = $dbh->prepare ($query) or die "prepare failed\n";
$sth->execute( ) or die "unable to execute query $query   error $DBI::errstr";

my $rows = $sth->rows ;

while ( @first = $sth->fetchrow_array ) {
   foreach $field (@first) {
      print "field: $field\n";
   }
}


mit strict und warnings bekomme ich folgende Meldung:
Code: (dl )
1
2
3
4
Global symbol "@first" requires explicit package name at test.pl line 20.
Global symbol "$field" requires explicit package name at test.pl line 21.
Global symbol "@first" requires explicit package name at test.pl line 21.
Global symbol "$field" requires explicit package name at test.pl line 22.


mit auskommentiertem Strict (um den Fehler von vorhin zu rekonstruieren) bekomme ich:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
DBI connect('host=myhost;port=1433;database=mydb','user',...) failed: Server message number=4064 severity=11 state=1 line=0 server=Servername\Instancename text=Cannot open user default database. Login failed.
Server message number=18456 severity=14 state=1 line=0 text=Login failed for user 'user'.
OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34)
Server , database
Message String: Adaptive Server connection failed
at test.pl line 9
unable to connect to server Server message number=4064 severity=11 state=1 line=0 server=Servername\Instancename text=Cannot open user default database. Login failed.
Server message number=18456 severity=14 state=1 line=0 text=Login failed for user 'user'.
OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34)
Server , database
Message String: Adaptive Server connection failed

View full thread DBD::Sybase default Datenbank angeben