skip to Main Content

I need help connecting my Web App to a remote database (SQL Server).
I have tried many suggested solutions but I can’t seem to come right.

This is how I connect to a local database, it works 100%:

<add name="DBCS" connectionString="Data Source=serverName;Initial Catalog=MVNE_Website;Integrated Security=True" providerName="System.Data.SqlClient" />

My ASP.NET Web App is hosted on one server, and the database is on a separate server.

The remote DB server is 100% configured to allow remote connections and firewall rules also adhere to the connection protocols. I think it is just my connection string that is incorrect but I don’t know why??

Here it is(conn string for remote SQL server)

<add name="DBCS" connectionString="server=serverIPserverName; database=MVNE_Website; Integrated Security=True" providerName="System.Data.SqlClient" />

I don’t use a username or password when connecting to this remote SQL Server so I did not see a point in adding it in the conn string?

2

Answers


  1. Chosen as BEST ANSWER

    :/

    In my web.config file custom errors mode was on RemoteOnly, so I turned it off and saw that my connection string was never the problem, the actual problem was that the app was trying to insert null into a primary key field that does not allow null, i never set the PK to auto increment .. sorry and thanks


  2. There can be a few reasons why this will not work. Here are 2 common ones:

    1. Your web application will pass the username the application pool is running under, (which by default is some system user) to SQL Server. Change this to be a service account which has access to SQL Server.

    2. If you are hopping across 2 or more servers to pass the credentials between IIS and SQL Server, you may need to implement Kerberos, which is a way to preserve the credentials. This is a complex network configuration thing.

    Check point 1 first.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search