Tuesday, March 27, 2012

DB access works in debug but fails when hosted

I have written a intranet page that writes some info into a sql database, basically following the 'SQL Server 2005 Express for Beginners' video.

When I debug the application from within 'Visual Web Develop 2005 express' it works fine entries are entered into the DB and I can then edit the db using the admin page.

But when I host the site using IIS I doesn't work, submissions to the database seem to fail I can see the DB in the admin page but if I try to edit them or delete them it fails.

What could I doing wrong could I be missing a setting in IIS? Any ideas??

Here's my webconfig if that helps at all:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="studentprofilesConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\studentprofiles.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
<compilation debug="true" defaultLanguage="c#" /></system.web></configuration

There is a posibility that if SQL server is not configured to accept remote connection it may fail. To enable remote connection follow this steps

Under SQL2005 program menu follow configuration Tools =>SQL Server Surface Area Configuration => Select Server Surface Area Configuration for Services and Connections.

It will lead to a window with a treeview select Remote connections.Then Select Local and Remote Connections.

Now if the error is due to Remote configuration issue it will be resolved

No comments:

Post a Comment