Wednesday, March 28, 2012

Please Help - Web application breaks when SQL .ldf file is relocat

Hi,
Here is the scenario:
My web developer is building a new site in asp.net, in turn he is using SQL
express in building his application. In my research on deploying SQL express
I have found it is in best practice to separate the .mdf and .ldf files to
different drives with adequate space. When he copies the database files he
has created from his local desktop up to the app_data folder on the web
server his database driven app works perfectly. Though when I go to move the
.ldf file to another location the application breaks, throwing the error
below. I have tried attaching the database to the management studio express
and configuring the location of the files but that did not work.
I have looked to into impersonation, metadata, and asp.net coding but am not
quite sure which may be causing this issue.
Please Help!!
Server Error in '/' Application.
---
---
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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: Cannot open user
default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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): Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +800131
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
timerExpire, SqlConnection owningObject) +172
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
host, String newPassword, Boolean redirectedUserInstance, SqlConnection
owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance) +181
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection) +357
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +494
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
System.Web.UI.Control.PreRenderRecursiveInternal() +86
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041It's nothing to do with the app codes. It's about the database.
After detaching your database and changing your log file's path, to attach
your database again run a script like the following according to your
situation.
CREATE DATABASE [Test] ON
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL.4\MSSQL\Data\Test.mdf' ),
( FILENAME = N'D:\Test_log.ldf' )
FOR ATTACH
--
Ekrem Ã?nsoy
"lca1630" <lca1630@.discussions.microsoft.com> wrote in message
news:D4F0B3BA-D066-4771-937A-0FF6579C69AB@.microsoft.com...
> Hi,
> Here is the scenario:
> My web developer is building a new site in asp.net, in turn he is using
> SQL
> express in building his application. In my research on deploying SQL
> express
> I have found it is in best practice to separate the .mdf and .ldf files to
> different drives with adequate space. When he copies the database files he
> has created from his local desktop up to the app_data folder on the web
> server his database driven app works perfectly. Though when I go to move
> the
> .ldf file to another location the application breaks, throwing the error
> below. I have tried attaching the database to the management studio
> express
> and configuring the location of the files but that did not work.
> I have looked to into impersonation, metadata, and asp.net coding but am
> not
> quite sure which may be causing this issue.
> Please Help!!
> Server Error in '/' Application.
> ---
> ---
> Cannot open user default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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: Cannot open user
> default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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): Cannot open user default database. Login
> failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> exception, Boolean breakConnection) +800131
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> stateObj) +186
> System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
> cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> bulkCopyHandler, TdsParserStateObject stateObj) +1932
> System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> enlistOK) +33
> System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> timerExpire, SqlConnection owningObject) +172
> System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
> +381
> System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> owningObject, SqlConnectionString connectionOptions, String newPassword,
> Boolean redirectedUserInstance) +181
> System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> identity, SqlConnectionString connectionOptions, Object providerInfo,
> String
> newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
> +173
> System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> owningConnection) +357
> System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
> owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
> System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
> owningObject) +424
> System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
> owningObject) +66
> System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
> owningObject) +494
> System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> owningConnection) +82
> System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> outerConnection, DbConnectionFactory connectionFactory) +105
> System.Data.SqlClient.SqlConnection.Open() +111
> System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
> DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
> srcTable,
> IDbCommand command, CommandBehavior behavior) +121
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord,
> Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
> behavior) +137
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
> +83
> System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
> arguments) +1770
> System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
> DataSourceViewSelectCallback callback) +17
> System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
> System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
> System.Web.UI.WebControls.GridView.DataBind() +4
> System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
> System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
> System.Web.UI.Control.PreRenderRecursiveInternal() +86
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
>
>|||Thank You for your imput, I will give it a try.
"Ekrem Ã?nsoy" wrote:
> It's nothing to do with the app codes. It's about the database.
> After detaching your database and changing your log file's path, to attach
> your database again run a script like the following according to your
> situation.
> CREATE DATABASE [Test] ON
> ( FILENAME = N'C:\Program Files\Microsoft SQL
> Server\MSSQL.4\MSSQL\Data\Test.mdf' ),
> ( FILENAME = N'D:\Test_log.ldf' )
> FOR ATTACH
> --
> Ekrem Ã?nsoy
>
> "lca1630" <lca1630@.discussions.microsoft.com> wrote in message
> news:D4F0B3BA-D066-4771-937A-0FF6579C69AB@.microsoft.com...
> > Hi,
> >
> > Here is the scenario:
> >
> > My web developer is building a new site in asp.net, in turn he is using
> > SQL
> > express in building his application. In my research on deploying SQL
> > express
> > I have found it is in best practice to separate the .mdf and .ldf files to
> > different drives with adequate space. When he copies the database files he
> > has created from his local desktop up to the app_data folder on the web
> > server his database driven app works perfectly. Though when I go to move
> > the
> > .ldf file to another location the application breaks, throwing the error
> > below. I have tried attaching the database to the management studio
> > express
> > and configuring the location of the files but that did not work.
> >
> > I have looked to into impersonation, metadata, and asp.net coding but am
> > not
> > quite sure which may be causing this issue.
> >
> > Please Help!!
> >
> > Server Error in '/' Application.
> > ---
> >
> > ---
> >
> > Cannot open user default database. Login failed.
> > Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> > 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: Cannot open user
> > default database. Login failed.
> > Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> >
> > 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): Cannot open user default database. Login
> > failed.
> > Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
> > System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> > exception, Boolean breakConnection) +800131
> >
> > System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> > stateObj) +186
> > System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
> > cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> > bulkCopyHandler, TdsParserStateObject stateObj) +1932
> > System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> > enlistOK) +33
> >
> > System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> > serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> > timerExpire, SqlConnection owningObject) +172
> > System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> > host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> > owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
> > +381
> >
> > System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> > owningObject, SqlConnectionString connectionOptions, String newPassword,
> > Boolean redirectedUserInstance) +181
> >
> > System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> > identity, SqlConnectionString connectionOptions, Object providerInfo,
> > String
> > newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
> > +173
> >
> > System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> > options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> > owningConnection) +357
> >
> > System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
> > owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
> > System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
> > owningObject) +424
> > System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
> > owningObject) +66
> > System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
> > owningObject) +494
> > System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> > owningConnection) +82
> > System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> > outerConnection, DbConnectionFactory connectionFactory) +105
> > System.Data.SqlClient.SqlConnection.Open() +111
> > System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
> > DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
> > srcTable,
> > IDbCommand command, CommandBehavior behavior) +121
> > System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> > startRecord,
> > Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
> > behavior) +137
> > System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
> > +83
> >
> > System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
> > arguments) +1770
> > System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
> > DataSourceViewSelectCallback callback) +17
> > System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
> > System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
> > System.Web.UI.WebControls.GridView.DataBind() +4
> > System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
> > System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
> > System.Web.UI.Control.PreRenderRecursiveInternal() +86
> > System.Web.UI.Control.PreRenderRecursiveInternal() +170
> > System.Web.UI.Control.PreRenderRecursiveInternal() +170
> > System.Web.UI.Control.PreRenderRecursiveInternal() +170
> > System.Web.UI.Control.PreRenderRecursiveInternal() +170
> > System.Web.UI.Page.ProcessRequestMain(Boolean
> > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
> >
> >
> >
> >
>|||I am wondering if anyone can look at the stack trace and give me an idea of
what if going on. Thanks
Server Error in '/' Application
----
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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: Cannot open user
default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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): Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +800131
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
timerExpire, SqlConnection owningObject) +172
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
host, String newPassword, Boolean redirectedUserInstance, SqlConnection
owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance) +181
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection) +133
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +494
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
System.Web.UI.Control.PreRenderRecursiveInternal() +86
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
----
Version Information: Microsoft .NET Framework Version:2.0.50727.1433;
ASP.NET Version:2.0.50727.1433
"lca1630" wrote:
> Hi,
> Here is the scenario:
> My web developer is building a new site in asp.net, in turn he is using SQL
> express in building his application. In my research on deploying SQL express
> I have found it is in best practice to separate the .mdf and .ldf files to
> different drives with adequate space. When he copies the database files he
> has created from his local desktop up to the app_data folder on the web
> server his database driven app works perfectly. Though when I go to move the
> .ldf file to another location the application breaks, throwing the error
> below. I have tried attaching the database to the management studio express
> and configuring the location of the files but that did not work.
> I have looked to into impersonation, metadata, and asp.net coding but am not
> quite sure which may be causing this issue.
> Please Help!!
> Server Error in '/' Application.
> ---
> ---
> Cannot open user default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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: Cannot open user
> default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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): Cannot open user default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> exception, Boolean breakConnection) +800131
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> stateObj) +186
> System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
> cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> bulkCopyHandler, TdsParserStateObject stateObj) +1932
> System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> enlistOK) +33
> System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> timerExpire, SqlConnection owningObject) +172
> System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
> System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> owningObject, SqlConnectionString connectionOptions, String newPassword,
> Boolean redirectedUserInstance) +181
> System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> identity, SqlConnectionString connectionOptions, Object providerInfo, String
> newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
> System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> owningConnection) +357
> System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
> System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
> owningObject) +424
> System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
> owningObject) +66
> System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
> owningObject) +494
> System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> owningConnection) +82
> System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> outerConnection, DbConnectionFactory connectionFactory) +105
> System.Data.SqlClient.SqlConnection.Open() +111
> System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
> DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
> IDbCommand command, CommandBehavior behavior) +121
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
> Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
> behavior) +137
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
> System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
> System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
> DataSourceViewSelectCallback callback) +17
> System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
> System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
> System.Web.UI.WebControls.GridView.DataBind() +4
> System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
> System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
> System.Web.UI.Control.PreRenderRecursiveInternal() +86
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
>
>|||Every Login has a default database which is set as "master" by default.
In cases such as yours, people change default database of a Login and then
they delete that database or something and then when they try to connect to
SQL Server using this Login they get this error because this Login' s
default database is not exist, it's not there anymore so it raises this
error.
Ensure that Network Service Login' s default database is set correctly. You
can correct this from your Login' s properties.
--
Ekrem Ã?nsoy
"lca1630" <lca1630@.discussions.microsoft.com> wrote in message
news:0FF290EE-3C57-4974-B9F5-90D6F3012288@.microsoft.com...
>I am wondering if anyone can look at the stack trace and give me an idea of
> what if going on. Thanks
> Server Error in '/' Application.
> ----
> Cannot open user default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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: Cannot open user
> default database. Login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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): Cannot open user default database. Login
> failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> exception, Boolean breakConnection) +800131
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> stateObj) +186
> System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
> cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> bulkCopyHandler, TdsParserStateObject stateObj) +1932
> System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> enlistOK) +33
> System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> timerExpire, SqlConnection owningObject) +172
> System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
> +381
> System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> owningObject, SqlConnectionString connectionOptions, String newPassword,
> Boolean redirectedUserInstance) +181
> System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> identity, SqlConnectionString connectionOptions, Object providerInfo,
> String
> newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
> +173
> System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> owningConnection) +133
> System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
> owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
> System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
> owningObject) +424
> System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
> owningObject) +66
> System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
> owningObject) +494
> System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> owningConnection) +82
> System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> outerConnection, DbConnectionFactory connectionFactory) +105
> System.Data.SqlClient.SqlConnection.Open() +111
> System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
> DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
> srcTable,
> IDbCommand command, CommandBehavior behavior) +121
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord,
> Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
> behavior) +137
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
> +83
> System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
> arguments) +1770
> System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
> DataSourceViewSelectCallback callback) +17
> System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
> System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
> System.Web.UI.WebControls.GridView.DataBind() +4
> System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
> System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
> System.Web.UI.Control.PreRenderRecursiveInternal() +86
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Control.PreRenderRecursiveInternal() +170
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
>
>
> ----
> Version Information: Microsoft .NET Framework Version:2.0.50727.1433;
> ASP.NET Version:2.0.50727.1433
> "lca1630" wrote:
>> Hi,
>> Here is the scenario:
>> My web developer is building a new site in asp.net, in turn he is using
>> SQL
>> express in building his application. In my research on deploying SQL
>> express
>> I have found it is in best practice to separate the .mdf and .ldf files
>> to
>> different drives with adequate space. When he copies the database files
>> he
>> has created from his local desktop up to the app_data folder on the web
>> server his database driven app works perfectly. Though when I go to move
>> the
>> .ldf file to another location the application breaks, throwing the error
>> below. I have tried attaching the database to the management studio
>> express
>> and configuring the location of the files but that did not work.
>> I have looked to into impersonation, metadata, and asp.net coding but am
>> not
>> quite sure which may be causing this issue.
>> Please Help!!
>> Server Error in '/' Application.
>> ---
>> ---
>> Cannot open user default database. Login failed.
>> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
>> 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: Cannot open user
>> default database. Login failed.
>> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
>> 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): Cannot open user default database. Login
>> failed.
>> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
>> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
>> exception, Boolean breakConnection) +800131
>> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
>> stateObj) +186
>> System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
>> SqlCommand
>> cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
>> bulkCopyHandler, TdsParserStateObject stateObj) +1932
>> System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
>> enlistOK) +33
>> System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
>> serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
>> timerExpire, SqlConnection owningObject) +172
>> System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
>> host, String newPassword, Boolean redirectedUserInstance, SqlConnection
>> owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
>> +381
>> System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
>> owningObject, SqlConnectionString connectionOptions, String newPassword,
>> Boolean redirectedUserInstance) +181
>> System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
>> identity, SqlConnectionString connectionOptions, Object providerInfo,
>> String
>> newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
>> +173
>> System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
>> options, Object poolGroupProviderInfo, DbConnectionPool pool,
>> DbConnection
>> owningConnection) +357
>> System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
>> owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
>> System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
>> owningObject) +424
>> System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
>> owningObject) +66
>> System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
>> owningObject) +494
>> System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
>> owningConnection) +82
>> System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
>> outerConnection, DbConnectionFactory connectionFactory) +105
>> System.Data.SqlClient.SqlConnection.Open() +111
>> System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
>> DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
>> srcTable,
>> IDbCommand command, CommandBehavior behavior) +121
>> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
>> startRecord,
>> Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
>> behavior) +137
>> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
>> srcTable) +83
>> System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
>> arguments) +1770
>> System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
>> arguments,
>> DataSourceViewSelectCallback callback) +17
>> System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
>> System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
>> System.Web.UI.WebControls.GridView.DataBind() +4
>> System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
>> System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24
>> System.Web.UI.Control.PreRenderRecursiveInternal() +86
>> System.Web.UI.Control.PreRenderRecursiveInternal() +170
>> System.Web.UI.Control.PreRenderRecursiveInternal() +170
>> System.Web.UI.Control.PreRenderRecursiveInternal() +170
>> System.Web.UI.Control.PreRenderRecursiveInternal() +170
>> System.Web.UI.Page.ProcessRequestMain(Boolean
>> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>> +2041
>>
>>

No comments:

Post a Comment