Learning
Learning

Reputation: 20031

SQL Connection string for asp.net

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?

Upvotes: 0

Views: 237

Answers (2)

Amir Rajabi
Amir Rajabi

Reputation: 1

You can use "." instead of ip address

Upvotes: 0

Eddie
Eddie

Reputation: 456

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.

Upvotes: 1

Related Questions