i use 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 the exception
Failed to connect to server.
Any Ideas?
[EDITED]
Inner Exception:
{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}