[freetds] TDS just 'died'

Constantin Vasilyev vasilyev at ncbi.nlm.nih.gov
Tue Jun 9 22:46:46 EDT 2009


The error is not related to FreeTDS, but rather to the SQL server itself.
Resetting login's default database to 'master' with this command should fix the problem:


alter login <loginname> with default_database = 'master'


I assume here that you're running SQL2005 or SQL2008.
For older versions use 'sp_defaultdb' stored procedure.


Constantin


On Tue, Jun 09, 2009 at 10:13:41PM -0400, James K. Lowden wrote:
> O'Neil, Donald A. wrote:
> > Our DB admin detached the DB from the MSSQL server, ran a backup and the
> > re-attached the DB, and ever since he did that we're getting errors on
> > our FreeTDS scripts:
> ...
> > Cannot open user default database
> ...
> > Login failed for user 'NOCReader'
> ...
> > Anyone have any ideas as to what could have happened on the SQL side of
> > things to break this?
> 
> No idea, except that it's a server issue, because those messages came from
> the server.  
> 
> Logins are defined by the server, not a database.  However, that "cannot
> open user default database" message says the user is no longer defined or
> allowed in the database.  
> 
> If the 'change to initial database must succeed' flag is set in the login
> packet (cf. http://www.freetds.org/tds.html#login7) the server will
> disconnect if the database is unavailable to the user.  
> 
> And it is set on:
> 
> $ grep -n option_flag1 src/tds/login.c
> 702:    unsigned char option_flag1 = 0x00;
> 797:    option_flag1 |= 0x80;   /* enable warning messages if SET LANGUAGE
> issued   */
> 798:    option_flag1 |= 0x40;   /* change to initial database must succeed
>          */
> 799:    option_flag1 |= 0x20;   /* enable warning messages if USE
> <database> issued */
> 801:    tds_put_byte(tds, option_flag1);
> 
> 
> HTH.  
> 
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds



More information about the FreeTDS mailing list