Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono crashes while connecting to a sql server with a certain instance name

I created a sql server instance called 'abcd' on my computer but when I try to connect to it I receive a strange error. I am able to connect to my others instances with the same code. Is the instance name causing this error?

Here is my code :

string connectionString = "Server=192.168.1.185\\abcd;" + "Database=test;" + "User ID=sa;" + "Password=bob;";

IDbConnection dbcon;
using (dbcon = new SqlConnection(connectionString))
{
    dbcon.Open(); // <-- crashes here
    Console.WriteLine("Connected");
}

Crash

Mono does not support names pipes or shared memory for connecting to SQL Server. Please enable the TCP/IP protocol.

What's wierd is that I'm able to connect to my other instances. The only thing that changes is the instance name.

I'm using Xamarin.iOS 9.4.0.0, Xamarin Studio 5.10.1, Mono Framework MDK 4.2.1.102

like image 736
skyjetsen Avatar asked Apr 17 '26 11:04

skyjetsen


1 Answers

In SQL server the enabled protocols are configured on a per-instance basis, so the most likely explanation is that the named instance you're trying to connect to doesn't have the TCP/IP protocol enabled.

You can check this by opening the Sql Server Configuration Manager tool and going to SQL Server Network Configuration -> Protocols for {instance name}. Make sure that the TCP/IP protocol is enabled.

like image 131
Jared Russell Avatar answered Apr 19 '26 00:04

Jared Russell