© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
Jibz

✅ cannot connect console dotnet project with microsoft SQL

I'm following this : https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-dotnet-core?view=azuresql-mi

I'm running microsoft sql from docker. I can access my database from azure data studio by setting server as "localhost" so I tried to do the same in my code. My confusion is here
builder.DataSource = "<your_server.database.windows.net>"; 
builder.DataSource = "<your_server.database.windows.net>"; 


setting "server" in azure data studio works so I thought it should work as well in code but it throws error when I do this:
    builder.DataSource = "localhost";
    builder.DataSource = "localhost";

or this
    builder.DataSource = "localhost.database.windows.net";
    builder.DataSource = "localhost.database.windows.net";


What am i doing wrong?
message.txt5.29KB
Use .NET to connect and query a database on Windows, Linux, or macO...
This topic shows you how to use .NET to create a program that connects to a database in Azure SQL Database, or Azure SQL Managed Instance, and queries it using Transact-SQL statements.
Use .NET to connect and query a database on Windows, Linux, or macO...
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Microsoft.Data.SqlClient.SqlException
C#CC# / help
3y ago
dotnet new console
C#CC# / help
4y ago
✅ dotnet.microsoft.com is down
C#CC# / help
2y ago
✅ Microsoft sql unable to connect. What I'm missing?
C#CC# / help
2y ago