Friday, February 17, 2012

error attaching .mdf

I have been asked to edit a web based database and have been given the site on cd.

I have installed IIS, sql server express and Visual Web Developer express.

I am having problems getting the mdf database connected. It works at the school where they have it installed and as far as I know I have mirrored the configuration they have on one of my test servers.

The database is in App_Data

the connection string is "Data Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\wwwroot\App_Data\campbell.mdf;Integrated Security=True;User Instance=True"

And the state is closed.

When I view one of the aspx pages in IE I get the following.

Server Error in '/' Application.

Configuration Error

Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message:It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:

Line 6: <compilation defaultLanguage="vb" debug="true" />Line 7: <customErrors mode="Off" />Line 8: <authentication mode="Windows" />Line 9: <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />Line 10: <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />


Source File:c:\inetpub\wwwroot\app\campbell_house\web.config Line:8

The common error is:

"Error 1 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. c:\inetpub\wwwroot\App\Campbell_House\Web.config 8 "

When I test the database connection I get a message

The header file for 'c:\inetpub\wwwroot\App_Data\campbell.mdf ' is not a valid database file header. The File Size property is incorrect. An attempt to attach an auto named database for file 'c:\inetpub\wwwroot\App_Data\campbell.mdf ' failed.A database with the same name existsor the specified file cannot be opened or it is located on a UNC share

Any help would be great.

Ok so I am pretty new to this but I am making progress. I had tried all afternoon and it wasn't until after I posted here that I had a brainwav.

Stage Two

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +173 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199 System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup) +1069 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +606 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +193 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +501 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +510 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89 System.Data.SqlClient.SqlConnection.Open() +160 CampbellHouse.CommonFunctions.GetConnection() +55 CampbellHouse.search.Page_Load(Object sender, EventArgs e) +347 System.Web.UI.Control.OnLoad(EventArgs e) +80 System.Web.UI.Control.LoadRecursive() +49 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745

Once again, hope someon can help me out here.

|||

Hi,

I believe the cause of the problem is due to the web.config file being located in a folder that isn't marked in IIS as an application.

Your web.config currently appears to be located in:

c:\inetpub\wwwroot\app\campbell_house

It contains settings which ASP.NET requires being declared for the entire web application (e.g. the <authentication ...> section).

Try making 'campbell_house' an application using IIS management console.

Good luck :)

Wayne.

|||I'we got the same problem, might this be because i'aint got an Internet Connection at my Home?

No comments:

Post a Comment