The following code example fails randomly on some PC's. On other PC's the problem cannot be reproduced. All PC's are running .NET 3.5 SP1 on Vista SP1.
string connection = @"Data Source=PCNAME\SQLEXPRESS;Database=TestDatabase ;User Id=sa;Password=ThePassword;";
TestDatabase db = new TestDatabase (connection);
if (!db.DatabaseExists())
{
db.CreateDatabase();
}
DatabaseExists()
returns false
but CreateDatabase()
throws this Exception:
System.Data.SqlClient.SqlException: Database 'TestDatabase ' already exists. Choose a different database name.
The documentation states that DatabaseExists()
returns true if the database exists and can be opened.
What could cause the database not to be available?