Web app access to the MS SQL Database works when debugging localhost but doesn't work once deployed to local IIS7 web server

Posted on 2011-04-21
Medium Priority
Last Modified: 2012-05-11
I've created a web application in ASP.NET with VB.NET as the code-behind using Visual Studio 2010. The web application is connected to a MS SQL Server 2005 database on a remote web server on the company's intranet. When I run the application as localhost through Visual Studio 2010 everything works fine, I'm able to login to the website, and access data within the database from the website, as well as insert data in to the database via the web form.

The problem is once I deploy this web application to my local web server set up with IIS 7, and try to browse the site, the site comes up, but anything on the site related to accessing the MS SQL database (ex. inserting data through form, loginng in to access protected pages) is not functional. And the browser does not return any kind of error whatsoever.

Please help,
Question by:rmitwiz
  • 2
LVL 31

Expert Comment

ID: 35443807
What are your security settings in the connectionstring to the database? Are you using SQL authentication or Windows authentication? http://www.connectionstrings.com/sql-server-2008

Are there database management tools e.g. SQL Server Management Studio on the web server - are you able to connect to the database from this server using SSMS?

Errors not showing on the interface might be due to how you are handling your exceptions. What are you doing with the exceptions in your Try...Catch blocks?

Author Comment

ID: 35444030
My connection string is as follows:
<add name="ConnectionStringpforms" connectionString="Data Source=servername; Initial Catalog=DatabaseName; Integrated Security=True" providerName="System.Data.SqlClient" />

Yes, I am able to connect to the database from the server using SSMS.

And I do not have any Try...Catch Blocks in my code.
And keep in mind everything works perfectly  on localhost. Just not once the web application is deployed to my local machine's IIS7 web server.
LVL 31

Accepted Solution

MlandaT earned 2000 total points
ID: 35444128
"Integrated Security=True" means you are running the application with windows authentication. Now, when you run on your machine, you are using a different account to the one being used by the web server to log onto the database. The web server will use the account under which IIS or more specifically, the account under which the application pool is running.

"Yes, I am able to connect to the database from the server using SSMS." that tells us that a connection to teh sql server is possible from the web server box. That eliminates network and firewall configurations etc etc.

To cut a long story short, I would recommend SQL Server authentication. Either use the "sa" account, or preferably, create a SQL account for your application with access to the database in question and setup your connection string to use that account.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question