0

I use SQL Server in an ASP.Net web application and connect database with this connection string:

<add name="SQLConnectionString" 
     connectionString="Data Source=204.93.xxx.xxx;Initial Catalog=some_Database;User ID=someUser;Password=somePassword" 
     providerName="System.Data.SqlClient"/>

Suppose our web server and SQL Server are on same machine then is it the right way of defining a connection string?

If we block SQL Server port 1433 from firewall will this connection string work as here we mention IP of the machine on which SQL Server is and SQL Server connects using port 1433

Or should we use localhost instead of IP address even then firewall block port 1433 then application might still work?

2
  • 1
    This might help databasejournal.com/features/mssql/article.php/3689846/… Commented Mar 5, 2015 at 5:52
  • If the SQL Server instance runs on the same machine as the web server, I'd just use . to denote "local machine". This connects as directly as possible Commented Mar 5, 2015 at 6:14

2 Answers 2

1

If you are on two separate Machines and you're blocking the port via a firewall, then no you will not be able to communicate to the MS SQL Server Service that is listening on the Port.

If you are on one physical Machine you would not specify the IP Address. You would use the named instance or localhost.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use "." instead of ip address

1 Comment

please extend this answer to explain what the . refers to as it could be construed as unclear for users that don't know about that. some links and reference material with quotations would be useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.