Can't immediately connect to newly-created SQL Server database

后端 未结 4 1717
傲寒
傲寒 2021-01-12 00:25

I\'m creating a database using SQL Server Management Objects.

I wrote the following method to generate a database:

public static void CreateClientDat         


        
4条回答
  •  渐次进展
    2021-01-12 00:27

    In my case it turned out that the problem is not that the newly created database is not ready. But the problem was that SqlConnection.Open() apparently used a failed cached connection, which then just returned the same error again.

    When I call the static SqlConnection.ClearAllPools() method before I try to open the newly created database, it works fine!

    See also this question.

提交回复
热议问题