Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

SQL Server Browser error when connecting to Docker Sql Server Container

Open davidecolella opened this issue 2 years ago • 0 comments

Hi, when trying to use Dapper from inside a C# .Net 7 API Docker Container to a Sql Server 2022 Docker Container i get an error: Cannot connect to SQL Server Browser. Ensure SQL Server Browser has been started.

The connection string has the IP adress of the Docker Sql container and the port specified (i have tried even with container name and port number). "Data Source=<ip adress>,1433;Initial Catalog=<db name>;Persist Security Info=True;User ID=<user>;Password=<strong password>;TrustServerCertificate=True;"

The Docker containers are on the same network and are visible to each other.

If i try to execute the same Stored Procedure/ Query using other methods (like SqlCommand)the connection is established and data is retrieved, so the Database is accessible.

Dapper Nuget version installed in C# .NET 7 Api solution: 2.1.24 I am using this Sql Server Docker image: "mcr.microsoft.com/mssql/server:2022-latest"

How can i solve this issue?

Thank you very much in advance.

davidecolella avatar Nov 23 '23 13:11 davidecolella