I am using this SMO code to attach a database.
Server mServer = new Server(".");
mServer.AttachDatabase("DbName", new StringCollection {
"DbName.mdf",
"DbName_log.LDF" }, AttachOptions.None);
But I keep getting an exception
Failed to connect to server.
Any ideas?
[Changed]
Internal exception:
{"A network-related or specific instance error occurred while establishing a connection to SQL Server. The server could not be found or is unavailable. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (Provider: named pipe provider, error: 40 - Could not open connection to SQL Server) "}
source
share