Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a website which is developed in asp.net 3.5 with c#. i am host this site on local host and sql server is on Local Server. I am not able to connect website with sql server. please help me to solve that problem

Thanx with regards
Ankush
Posted
Updated 25-Jun-13 19:54pm
v2
Comments
Tiwari Avinash 26-Jun-13 2:06am    
Will you please elaborate your problem, what exception or error your getting.

Awesome MSDN article for you to get started.

SQL Server Connection Strings for ASP.NET Web Applications[^].
 
Share this answer
 
v2
for your reference..

ASP.NET as such does not differentiate local and remote database servers. The things you might want to take care though are

1. Have the connection string point to the database serverusing its IP address and port

2. You also need a user name and password to access the database since the Integrated Security cannot be used. You can use integrated security if both the web server and database server are running under a single network domain trust.

3. Ensure that the port used to access the database is opened for Outbound traffic in your web server's firewall

The real thing you have to pay attention on it is the SERVER NAME / IP ADDRESS : PORT of the server - so, your Web.config connection string should look like the following:

XML
<connectionStrings>
  <add name="MyConnectionString" connectionString="Data Source=SERVER-IP:PORT;Database=DBName;User Name=<user>;Password=<pass>" providerName="System.Data.SqlClient" />
</connectionStrings>



more on connection strings is here http://www.connectionstrings.com/[^]
 
Share this answer
 
Comments
AnkushSharma100 26-Jun-13 2:21am    
Thanx Dear..
Tiwari Avinash 26-Jun-13 5:08am    
welcome!
firstly you need to grant permission on sql database to access it to remote and the website webconfig used to ConnectionString with datasource="ip address of remote system/server name">
 
Share this answer
 
v2
Comments
AnkushSharma100 26-Jun-13 2:22am    
Thanx dear..
You can connect the DATABASE by connectionstring.

XML
<connectionStrings>
<add name="ConnectionName" connectionString="Data Source=RemoteServerName;Initial Catalog=DBNAME; Integrated Security=True;/>
</connectionStrings>


Write the Code in Web.config
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900