sqldev -> myserver/MSSQLSERVERDEV
Мне интересно, возможно ли это использовать этот псевдоним в строке подключения. (пример ниже).
Код: Выделить всё
static void Main(string[] args)
{
OpenSqlConnection();
Console.Read();
}
private static void OpenSqlConnection()
{
try
{
string connectionString = GetConnectionString();
using (SqlConnection connection = new SqlConnection())
{
connection.ConnectionString = connectionString;
connection.Open();
Console.WriteLine("State: {0}", connection.State);
Console.WriteLine("ConnectionString: {0}",
connection.ConnectionString);
}
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
static private string GetConnectionString()
{
return "Data Source=sqldev;Initial Catalog=Data;"
+ "Integrated Security=true;";
}
Код: Выделить всё
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)
Подробнее здесь: https://stackoverflow.com/questions/791 ... tionstring
Мобильная версия