From: shapper on
Hello,

I am testing a web application on IIS on my personal computer and I
get the following error:

Login failed for user ''.
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: Login failed
for user ''.

My connection string is as follows:

<connectionStrings>
<add
name="Company.Domain.Properties.Settings.CompanyConnectionString"
connectionString="Data Source=FOD\SQLEXPRESS;Initial
Catalog=Company;Integrated Security=False"
providerName="System.Data.SqlClient" />
</connectionStrings>

I am loged on in Windows as Miguel which is Administrator.

FOD is the WorkGroup I set when installing windows.

Everything was working when testing under using VS 2008.

I only change Integrated Security=True to Integrated Security=False
because I was getting an error.

What do I need to change to make this work?

Thanks,
Miguel




From: Russell Fields on
Miguel,

In your connection string, I do not see the user id and password. That is
why you are getting user '', since the connection string does not know who
you want to be, such as:

Integrated Security=False;user id=SQLLogin;password=PasswordOfTheSQLLogin;

So, create a SQL Server login, give it a password, and use it in your
connection string.

However, when Integrated Security=True you attempt to login using your
Windows account, instead of a SQL Server login. You mentioned that you were
getting an error, but not what the error was. If you want to use your
Windows account, then you need a solution to the original problem that you
experienced.

RLF


"shapper" <mdmoura(a)gmail.com> wrote in message
news:b767c158-a6d9-4a9d-bfa8-8180b6436f5d(a)g3g2000vbr.googlegroups.com...
> Hello,
>
> I am testing a web application on IIS on my personal computer and I
> get the following error:
>
> Login failed for user ''.
> 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: Login failed
> for user ''.
>
> My connection string is as follows:
>
> <connectionStrings>
> <add
> name="Company.Domain.Properties.Settings.CompanyConnectionString"
> connectionString="Data Source=FOD\SQLEXPRESS;Initial
> Catalog=Company;Integrated Security=False"
> providerName="System.Data.SqlClient" />
> </connectionStrings>
>
> I am loged on in Windows as Miguel which is Administrator.
>
> FOD is the WorkGroup I set when installing windows.
>
> Everything was working when testing under using VS 2008.
>
> I only change Integrated Security=True to Integrated Security=False
> because I was getting an error.
>
> What do I need to change to make this work?
>
> Thanks,
> Miguel
>
>
>
>

From: shapper on
On Oct 19, 9:25 pm, "Russell Fields" <russellfie...(a)nomail.com> wrote:
> However, when Integrated Security=True you attempt to login using your
> Windows account, instead of a SQL Server login.  You mentioned that you were
> getting an error, but not what the error was.  If you want to use your
> Windows account, then you need a solution to the original problem that you
> experienced.

I would like to use integrated security. When it is true I get the
following error:

Cannot open database "BonsAlunos" requested by the login. The 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
database "BonsAlunos" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

[SqlException (0x80131904): Cannot open database "BonsAlunos"
requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +248
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning
(TdsParserStateObject stateObj) +245
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) +2811
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin
(Boolean enlistOK) +53
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin
(ServerInfo serverInfo, String newPassword, Boolean
ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
+327
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover
(String host, String newPassword, Boolean redirectedUserInstance,
SqlConnection owningObject, SqlConnectionString connectionOptions,
Int64 timerStart) +2445370
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist
(SqlConnection owningObject, SqlConnectionString connectionOptions,
String newPassword, Boolean redirectedUserInstance) +2445224
System.Data.SqlClient.SqlInternalConnectionTds..ctor
(DbConnectionPoolIdentity identity, SqlConnectionString
connectionOptions, Object providerInfo, String newPassword,
SqlConnection owningObject, Boolean redirectedUserInstance) +354
System.Data.SqlClient.SqlConnectionFactory.CreateConnection
(DbConnectionOptions options, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection) +703
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection
(DbConnection owningConnection, DbConnectionPool pool,
DbConnectionOptions options) +54
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject) +2414776
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest
(DbConnection owningObject) +92
System.Data.ProviderBase.DbConnectionPool.GetConnection
(DbConnection owningObject) +1657
System.Data.ProviderBase.DbConnectionFactory.GetConnection
(DbConnection owningConnection) +84
System.Data.ProviderBase.DbConnectionClosed.OpenConnection
(DbConnection outerConnection, DbConnectionFactory connectionFactory)
+1645767
System.Data.SqlClient.SqlConnection.Open() +258
System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection
(IConnectionUser user) +65
System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() +33
System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() +32

System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute
(Expression query) +63

System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator
() +45
System.Linq.Enumerable.Count(IEnumerable`1 source) +206
BonsAlunos.Infrastructure.CollectionExtensions.Random(IEnumerable`1
collection) in C:\Users\Miguel\Projects\BonsAlunos\Solution
\BonsAlunos.Infrastructure\CollectionExtensions.cs:87
BonsAlunos.Domain.Services.SlideService.GetRandom() in C:\Users
\Miguel\Projects\BonsAlunos\Solution\BonsAlunos.Domain\Services
\SlideService.cs:93
BonsAlunos.Presentation.Controllers.SlideController.Show() in C:
\Users\Miguel\Projects\BonsAlunos\Solution\BonsAlunos.Presentation
\Controllers\SlideController.cs:179
lambda_method(ExecutionScope , ControllerBase , Object[] ) +30
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters) +236
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
(ControllerContext controllerContext, ActionDescriptor
actionDescriptor, IDictionary`2 parameters) +31

System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7
() +85
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter
(IActionFilter filter, ActionExecutingContext preContext, Func`1
continuation) +235971
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters
(ControllerContext controllerContext, IList`1 filters,
ActionDescriptor actionDescriptor, IDictionary`2 parameters) +288
System.Web.Mvc.ControllerActionInvoker.InvokeAction
(ControllerContext controllerContext, String actionName) +236150
System.Web.Mvc.Controller.ExecuteCore() +174
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) +209
Microsoft.Web.Mvc.ViewExtensions.RenderRoute(HtmlHelper helper,
RouteValueDictionary routeValues) +424
Microsoft.Web.Mvc.ViewExtensions.RenderAction(HtmlHelper helper,
String actionName, String controllerName, RouteValueDictionary
routeValues) +576
ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w,
Control parameterContainer) in c:\inetpub\wwwroot\BonsAlunos\Views
\Shared\Site.Master:19
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +115
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +240
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +240
System.Web.UI.Page.Render(HtmlTextWriter writer) +38
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +89
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+4240

Do you know why I get this error?

Thanks,
Miguel



From: Russell Fields on
I believe that you got an answer from Erland in your later post. If not,
you can respond to this. - RLF

"shapper" <mdmoura(a)gmail.com> wrote in message
news:5513992d-734d-421a-a8b2-f14e6df0db23(a)d23g2000vbm.googlegroups.com...
On Oct 19, 9:25 pm, "Russell Fields" <russellfie...(a)nomail.com> wrote:
> However, when Integrated Security=True you attempt to login using your
> Windows account, instead of a SQL Server login. You mentioned that you
> were
> getting an error, but not what the error was. If you want to use your
> Windows account, then you need a solution to the original problem that you
> experienced.

I would like to use integrated security. When it is true I get the
following error:

Cannot open database "BonsAlunos" requested by the login. The 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
database "BonsAlunos" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

[SqlException (0x80131904): Cannot open database "BonsAlunos"
requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +248
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning
(TdsParserStateObject stateObj) +245
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) +2811
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin
(Boolean enlistOK) +53
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin
(ServerInfo serverInfo, String newPassword, Boolean
ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
+327
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover
(String host, String newPassword, Boolean redirectedUserInstance,
SqlConnection owningObject, SqlConnectionString connectionOptions,
Int64 timerStart) +2445370
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist
(SqlConnection owningObject, SqlConnectionString connectionOptions,
String newPassword, Boolean redirectedUserInstance) +2445224
System.Data.SqlClient.SqlInternalConnectionTds..ctor
(DbConnectionPoolIdentity identity, SqlConnectionString
connectionOptions, Object providerInfo, String newPassword,
SqlConnection owningObject, Boolean redirectedUserInstance) +354
System.Data.SqlClient.SqlConnectionFactory.CreateConnection
(DbConnectionOptions options, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection) +703
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection
(DbConnection owningConnection, DbConnectionPool pool,
DbConnectionOptions options) +54
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject) +2414776
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest
(DbConnection owningObject) +92
System.Data.ProviderBase.DbConnectionPool.GetConnection
(DbConnection owningObject) +1657
System.Data.ProviderBase.DbConnectionFactory.GetConnection
(DbConnection owningConnection) +84
System.Data.ProviderBase.DbConnectionClosed.OpenConnection
(DbConnection outerConnection, DbConnectionFactory connectionFactory)
+1645767
System.Data.SqlClient.SqlConnection.Open() +258
System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection
(IConnectionUser user) +65
System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() +33
System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() +32

System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute
(Expression query) +63

System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator
() +45
System.Linq.Enumerable.Count(IEnumerable`1 source) +206
BonsAlunos.Infrastructure.CollectionExtensions.Random(IEnumerable`1
collection) in C:\Users\Miguel\Projects\BonsAlunos\Solution
\BonsAlunos.Infrastructure\CollectionExtensions.cs:87
BonsAlunos.Domain.Services.SlideService.GetRandom() in C:\Users
\Miguel\Projects\BonsAlunos\Solution\BonsAlunos.Domain\Services
\SlideService.cs:93
BonsAlunos.Presentation.Controllers.SlideController.Show() in C:
\Users\Miguel\Projects\BonsAlunos\Solution\BonsAlunos.Presentation
\Controllers\SlideController.cs:179
lambda_method(ExecutionScope , ControllerBase , Object[] ) +30
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters) +236
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
(ControllerContext controllerContext, ActionDescriptor
actionDescriptor, IDictionary`2 parameters) +31

System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7
() +85
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter
(IActionFilter filter, ActionExecutingContext preContext, Func`1
continuation) +235971
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters
(ControllerContext controllerContext, IList`1 filters,
ActionDescriptor actionDescriptor, IDictionary`2 parameters) +288
System.Web.Mvc.ControllerActionInvoker.InvokeAction
(ControllerContext controllerContext, String actionName) +236150
System.Web.Mvc.Controller.ExecuteCore() +174
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) +209
Microsoft.Web.Mvc.ViewExtensions.RenderRoute(HtmlHelper helper,
RouteValueDictionary routeValues) +424
Microsoft.Web.Mvc.ViewExtensions.RenderAction(HtmlHelper helper,
String actionName, String controllerName, RouteValueDictionary
routeValues) +576
ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w,
Control parameterContainer) in c:\inetpub\wwwroot\BonsAlunos\Views
\Shared\Site.Master:19
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +115
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +240
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +240
System.Web.UI.Page.Render(HtmlTextWriter writer) +38
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +89
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+4240

Do you know why I get this error?

Thanks,
Miguel