SQL Server connection randomly returns 233 or 18456 error codes

When I tried to check an invalid connection string with an instance of SQL Server 2008 Express, I found this strange behavior: specifying an invalid Initial Catalogcalls SQLException, the number of which is sometimes 233, and sometimes 18456.

The code can better illustrate it.

// The following connection string has a purposely incorrect initial catalog:
string invalidConnString = @"Data Source=.\SQLEXPRESS;Initial Catalog=INVALID_DATABASE_NAME;User Id=dummyUser;Password=dummyPassw;";

SqlConnection connection = new SqlConnection(invalidConnString);

try
{
    connection.Open();
}
catch (SqlException sex)
{
    Console.WriteLine(sex.Number); // I "randomly" get either 233 or 18456
    throw;
}
finally
{
    connection.Close();
}

system error codes from the Books online store determine that

  • 233 . The connection to the server was successfully established, but then an error occurred during the registration process. (provider: shared memory provider, error: 0 - no process is on the other end of the pipe.)
  • 18456 - Login failed for user '%. * ls'.%. * ls

, : . , ?

+3
1

,

SQL Express, , SQL Express AUTO_CLOSE. , . , , .

AUTO_CLOSE , , .

low - .

ALTER DATABASE DBNAME SET AUTO_CLOSE OFF

http://msdn.microsoft.com/en-us/library/bb522682.aspx

+3

Source: https://habr.com/ru/post/1759453/


All Articles