issue with connecting ms sql azure

Andy Qian <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Hello, FreeTDS community,

I tried to connect ms sql azure by using perl's DBD:Sybase driver.

The basic structure is:  Perl code =>  DBI =>  DBD:Sybase driver =>  freeTDS ------>  ms sql azure server.

the connection code is:

$dbh = DBI->connect("dbi:sybase:server=azure;database=testdb", "user@serv123", $pwd);


the corresponding entry "azure" in .freetds.conf is

[azure]
      host = serv123.database.windows.net
      port = 1433
      encryption = required
      client charset = UTF-8
      tds version = 7.1


perl version is 5.8.3
DBD:Sybase version: 1.13
FreeTDS version: 0.91
ubuntu version: 10.04 LTS



with the specified default database, I got the following error message:


DBI connect('database=testdb;server=serv123.database.windows.net','user@serv123',...) failed: Server message number=4060 severity=11 state=1 line=1  server=serv123 text=Cannot open database "master" requested by the login. The login failed.


The direct reason causing this problem is that login user does not have access into master database.

By tracing TDSDUMP info of connecting to other version ms sql server, I found it looks like that DBD::Sybase always logins to master database firstly, and then switches to the database specified in the dsn string by executing "use $database" statement.

   it is also mentioned in DBD::Sybase man page
(http://search.cpan.org/~mewp/DBD-Sybase-1.13/Sybase.pm#Specifying_other_connection_specific_parameters),

$dbh  =  DBI->connect("dbi:Sybase:database=sybsystemprocs",
                           $user,  $passwd);

is equivalent to

$dbh  =  DBI->connect('dbi:Sybase:',  $user,  $passwd);
$dbh->do("use sybsystemprocs");


However, in the case of ms sql Azure, it does not support "use $database" statement. Any connection to Azure should be associated with default database directly.

I tried to use tsql to connect Azure with the specified default database, and it worked.

I am wondering if there is any people who came across the same issue and if there is any way I can solve this issue.

any suggestion will be very helpful.

Thank you very much.


Andy Qian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.