Database Connection problem

Last post 09-30-2009 9:44 AM by mehmeterdgn. 14 replies.

Sort Posts:

  • Database Connection problem

    08-09-2005, 4:24 PM
    • Member
      15 point Member
    • davidallan
    • Member since 08-09-2005, 3:53 PM
    • Posts 3

    I installed the app and it seemed to go fine.

    When I started it, the login screen came up and when I tried to login admin/admin I got the following

    ---------------------------------------------------------------------------------------------------------------------------------------------------------

    Server user 'LOHENGRIN02\ASPNET' is not a valid user in database 'IssueTrackerStarterKit'. Cannot open database requested in login 'IssueTrackerStarterKit'. Login fails. Login failed for user 'LOHENGRIN02\ASPNET'.

    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: Server user 'LOHENGRIN02\ASPNET' is not a valid user in database 'IssueTrackerStarterKit'. Cannot open database requested in login 'IssueTrackerStarterKit'. Login fails. Login failed for user 'LOHENGRIN02\ASPNET'.

    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: Server user 'LOHENGRIN02\ASPNET' is not a valid user in database 'IssueTrackerStarterKit'.
    Cannot open database requested in login 'IssueTrackerStarterKit'. Login fails.
    Login failed for user 'LOHENGRIN02\ASPNET'.]
       System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
       System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
       System.Data.SqlClient.SqlConnection.Open() +384
       ASPNET.StarterKit.IssueTracker.DataAccessLayer.SQLDataAccessLayer.ExecuteScalarCmd(SqlCommand sqlCmd) +132
       ASPNET.StarterKit.IssueTracker.DataAccessLayer.SQLDataAccessLayer.Authenticate(String username, String password) +192
       ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.ITUser.Authenticate(String username, String password) +44
       ASPNET.StarterKit.IssueTracker.DesktopDefault.Login(Object s, EventArgs e) +94
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain() +1292
    

    ------------------------------------------------------------------------------------------------------------------------------------

    What have I done wrong????

  • Re: Database Connection problem

    08-09-2005, 7:09 PM
    • Star
      12,495 point Star
    • adec
    • Member since 06-15-2002, 2:12 PM
    • Malmoe, Sweden
    • Posts 2,491
    Add the account "LOHENGRIN02\ASPNET" to the User list for your database "'IssueTrackerStarterKit'". Use Enterprose Manager, Query Ananlyser or the OSQL Commandline tool for this. You then need to give this account necessary priviledges to Execute Stored Procedure, and SELECT, INSERT, UPDATE and DELETE records from the mentioned DataBase.

    Read more.
    Regards

    Andre Colbiornsen
    ---------------------------------
    Seventh Day
    Råbygatan 1A,
    SE-223 61 Lund
    Sweden
    Mob.: +46-(0)708-97 78 79
    Mail: info@seventhday.se
    --------------------------------
  • Re: Database Connection problem

    08-10-2005, 4:31 PM
    • Member
      15 point Member
    • davidallan
    • Member since 08-09-2005, 3:53 PM
    • Posts 3

    I had that account (which only shows up as ASPNET beacause LOHENGRIN02 is the name of the computer).

    To be sure, I dropped that user and added it again. It was configured with dbowner authority on all of the databases.

    The result was the same.

  • Re: Database Connection problem

    08-10-2005, 11:31 PM
    • Star
      12,495 point Star
    • adec
    • Member since 06-15-2002, 2:12 PM
    • Malmoe, Sweden
    • Posts 2,491
    The <machinename>|LOHENGRIN02\ASPNET account is a low priviledge account added to your system when installing the .Net Framework. It cannot do much, and if you need to write to folders/upload files etc. the account must be given write access to the folders in question.

    To use the account for Db access, you add it to your SQL Server Instance, and assign it to the DBO group. But this is not enough. You need to get the properties for your Issue Tracker Db, find the ASP user under Users, click properties and open permissions. Now you will do the tedious task of checking every single checkbox for all Tables, Sprocs, functions etc. Before this is done, your ASPNET account cannot do much at all.
    Regards

    Andre Colbiornsen
    ---------------------------------
    Seventh Day
    Råbygatan 1A,
    SE-223 61 Lund
    Sweden
    Mob.: +46-(0)708-97 78 79
    Mail: info@seventhday.se
    --------------------------------
  • Re: Database Connection problem

    04-18-2006, 10:47 AM
    • Member
      97 point Member
    • hwadhwa
    • Member since 02-11-2003, 4:48 PM
    • Posts 20

    David

    Were you able to solve this problem? Because I am also having the same problem. And trying to resolve.

    Thanks

    H

     

    Cannot open database "IssueTrackerStarterKit" requested by the login. The login failed.
    Login failed for user 'DTS-D456L81\ASPNET'.

    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 "IssueTrackerStarterKit" requested by the login. The login failed.
    Login failed for user 'DTS-D456L81\ASPNET'.

    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 database "IssueTrackerStarterKit" requested by the login. The login failed.
    Login failed for user 'DTS-D456L81\ASPNET'.]
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734979
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
       System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
       System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
       System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359
       System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
       System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
       System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
       System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
       System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
       System.Data.SqlClient.SqlConnection.Open() +111
       ASPNET.StarterKit.IssueTracker.DataAccessLayer.SQLDataAccessLayer.ExecuteScalarCmd(SqlCommand sqlCmd) +123
       ASPNET.StarterKit.IssueTracker.DataAccessLayer.SQLDataAccessLayer.Authenticate(String username, String password) +177
       ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.ITUser.Authenticate(String username, String password) +44
       ASPNET.StarterKit.IssueTracker.DesktopDefault.Login(Object s, EventArgs e) +74
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

  • Re: Database Connection problem

    04-18-2006, 12:13 PM
    • Member
      109 point Member
    • Dycacian
    • Member since 02-27-2006, 6:51 PM
    • Posts 23

    Are you using XP or Server?  If you are using Server you have to use the NT Authority\Network Service instead of HostName\ASPNET

    -Dycacian
  • Re: Database Connection problem

    12-15-2006, 10:50 AM
    • Member
      39 point Member
    • codefloater
    • Member since 12-11-2006, 8:19 PM
    • Posts 13
    Was this problem ever resolved? i have the same issue and im trying to connect using an ip address, database name, uid, and pwd. I think the problem is they folks here normally use windows authentication....im not sure on how to incorporate that into the connection string...any help would be great. THX!
  • Re: Database Connection problem

    02-25-2007, 9:58 PM
    • Member
      2 point Member
    • swati14p
    • Member since 02-25-2007, 11:32 PM
    • Posts 1

    Hi All,

    I am facing the same database connection problem.

    Can anyone please tell me from where do i download /install

    "Use Enterprose Manager, Query Ananlyser or the OSQL Commandline tool for this."

    To solve this problem as discussed in the forum.

    Thanks

  • Re: Database Connection problem

    03-02-2007, 8:59 PM
    • Member
      636 point Member
    • irasmith
    • Member since 01-09-2004, 8:36 AM
    • Tennessee
    • Posts 176

    If you are using the MSDE version of SQL 2000 then if you did like I did when I acquired it and paid for it, then you should have Enterprise Manager tools on the CD that MSDE SQL 2000 came on.  If you downloaded MSDE, the free edition, there isn't an Enterprise Manager tool that came with it.

    If you are using SQL 2005 Express editions, then you can go to http://msdn.microsoft.com/vstudio/express/sql/download/ and you can download the Management Studio Express which will allow you to manage SQL User accounts and establish their permissions within databases.

    Hope this helps.

  • Re: Database Connection problem

    04-03-2007, 8:37 AM
    • Member
      13 point Member
    • lakmalvbj
    • Member since 04-03-2007, 12:06 PM
    • United Kingdom
    • Posts 49

    Add "machinename\ASPNET user to  login (Tip - Go to MsQL server Management studio, security , Login, right click, new login)

    Then give permission to that login for write, and database access

    Regards

    Each and Every problem has Solutions
  • Re: Database Connection problem

    07-27-2007, 8:42 PM
    • Member
      16 point Member
    • pabloat
    • Member since 07-28-2007, 12:38 AM
    • Posts 3

    Hi,

    I have this problem connecting to SQL server 2005.

    I am using a hosting that has sql server. i am getting this error message:

     

    Server Error in '/tejiendofuturo.com.ar' Application.

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

    Source Error:

    Line 825:            this.Adapter.SelectCommand = this.CommandCollection[2];
    Line 826: DSProducto.ProductoDataTable dataTable = new DSProducto.ProductoDataTable();
    Line 827: this.Adapter.Fill(dataTable);
    Line 828: return dataTable;
    Line 829: }

    Source File: e:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\tejiendofuturo.com.ar\e422f5f4\75a347ff\App_Code.uazcvh_f.4.cs    Line: 827

    Stack Trace:
     

     

    The connection string i am using is:

    connectionString="data source=localhost;integrated security=SSPI;initial catalog=wi720289_TejiendoFuturo;User ID=wi720289_tejiendofuturo;Password=whatever" 

    wi720289_ was set by the hosting web admin when i created the db and user.

    Thx.

    Bye. 

  • Re: Database Connection problem

    07-31-2007, 7:37 PM
    • Member
      636 point Member
    • irasmith
    • Member since 01-09-2004, 8:36 AM
    • Tennessee
    • Posts 176

    As a starting point to troubleshoot your connection problem, the "data source = localhost" might be your problem.  The only time this is valid is when the SQL Server is on the same machine as the web server where your web site files are loaded at.  It has been my experience that hosting providers usually have the web server on one machine and the database server on another machine.  Check with your hosting provider and find out if the SQL Server is on the same machine as the web server, if that is the case then the localhost setting is correct.  If that is not the case, then you would need to find out from your hosting provider what address you should use in the connection string to connect to the machine that has SQL Server and your database.

    Hope this helps.

     

  • Re: Database Connection problem

    08-02-2007, 10:28 AM
    • Member
      16 point Member
    • pabloat
    • Member since 07-28-2007, 12:38 AM
    • Posts 3

    Thanks. The problem was that the hosting needed for asp.net 2.0 to use another account than the asp one.

    To do this you have to put this line in the web.config file: <identity impersonate="true"/> 

    Bye and thx for the replay. 

     

  • Re: Database Connection problem

    07-08-2009, 3:53 AM
    • Member
      2 point Member
    • Johnisag
    • Member since 07-08-2009, 7:41 AM
    • Athens
    • Posts 1

     Hello. i have faced the same problem during the development of a web application for my thesis.

    The following works for me:

    On SQL Server Management Studio==>new query and jot down the following code:

    (with Win XP pro, IIS 5 and MS SQL 2005)

    exec sp_grantlogin 'MachineName\ASPNET'
    use database_name
    exec sp_grantdbaccess 'MachineName\ASPNET'
    exec sp_addrolemember 'db_owner', 'MachineName\ASPNET'
    

    (with win server 2008, iis 7 and sql server 2008)

    exec sp_grantlogin 'NT Authority\Network Service'
    use database_name
    exec sp_grantdbaccess 'NT Authority\Network Service'
    exec sp_addrolemember 'db_owner', 'NT Authority\Network Service'
    



     

     

     

  • Re: Database Connection problem

    09-30-2009, 9:44 AM
    • Member
      4 point Member
    • mehmeterdgn
    • Member since 08-19-2009, 10:15 AM
    • Posts 12

     Thank you so much. I used the solution and it works.

Page 1 of 1 (15 items)