I am trying to use the SMO library and setting the single user mode. Here is a simple example illustrating my issue.
The below code will fail the first time. Saying "Invalid object name TestTable". Eventhough that table does exist and so does the DB. However, if you run it again (now the DB is already in single user mode) everything works fine. Also, if you remove the
code that alters the db user mode everything works fine. I am assuming the problem must exist with the single user mode and utilizing the correct db connection. I have tried flipping the AutoDisconnectMode and NonPooledConnection but that hasn't help. Any
help would be appreciated.
SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();
sb.Password = "P@ssword!";
sb.UserID = "testuser";
sb.DataSource = @".\mssql2008";
sb.InitialCatalog = "TestDB";
ServerConnection serverConn = new ServerConnection();
//serverConn.AutoDisconnectMode = AutoDisconnectMode.NoAutoDisconnect;
View Complete Post