Results 1 to 11 of 11

Thread: Database connection error.

  1. #1
    Join Date
    Oct 2008
    Posts
    22

    Database connection error.

    Hi All,
    I created a asp.net website on my local with MS-SQL Server 2005 as database. I created the database locally. I then published the website.
    But when i tried to access the site using the url "http://machinename/projectname/default.aspx" it gave the database error as "Cannot open database "myDatabase" requested by the login. The login failed. Login failed for user 'my user'."
    Tried to google for the solution but was not resovled.
    Please guide me on this.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    How does asp talk to sql? Can you post connection string?

  3. #3
    Join Date
    Oct 2008
    Posts
    22
    Hi rmiao,
    the project is in .NET. Connection string is below

    <add key="ConnectionStringName" value="Data Source=machinename\SQLEXPRESS;Initial Catalog=databasename;Integrated Security=True"/>

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,922
    Have you granted access to sql server for asp.net service account

  5. #5
    Join Date
    Sep 2002
    Posts
    5,938
    Have to create sql login for that account.

  6. #6
    Join Date
    Oct 2008
    Posts
    22
    Hi skhanal, how do i do that??

  7. #7
    Join Date
    Nov 2008
    Posts
    1

    remote access

    Remote connections must be enabled on sql20005 express- look at this link
    http://forums.asp.net/p/1302020/2547594.aspx

    It says:
    Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition
    loadTOCNode(2, 'moreinformation');You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
    2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
    3. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.

    Note Click OK when you receive the following message:
    Changes to Connection Settings will not take effect until you restart the Database Engine service.
    4. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

    If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. For example, SQL Server 2005 Express is installed with a default instance name of Computer Name\SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps.

    Important These steps may increase your security risk. These steps may also make your computer or your network more vulnerable to attack by malicious users or by malicious software such as viruses. We recommend the process that this article describes to enable programs to operate as they are designed to, or to implement specific program capabilities. Before you make these changes, we recommend that you evaluate the risks that are associated with implementing this process in your particular environment. If you choose to implement this process, take any appropriate additional steps to help protect your system. We recommend that you use this process only if you really require this process.

  8. #8
    Join Date
    Sep 2002
    Posts
    5,938
    But in this case, sounds more likely permission issue based on error message.

    prashant12se, books online tells you how to create sql login.
    Last edited by rmiao; 11-09-2008 at 07:43 PM.

  9. #9
    Join Date
    Oct 2008
    Posts
    22
    Hi jensriis,
    i tried making changes in the settings as mentioned above, but still when i try to access the database remotely, it's giving the same error i.e "Cannot open database 'myDatabase' requested by the login. The login failed. Login failed for user 'my user'."

  10. #10
    Join Date
    Sep 2002
    Posts
    5,938
    prashant12se, did you check sql login? That's the problem you have now.

  11. #11
    Join Date
    Oct 2008
    Posts
    22
    Hi guys,
    sorry to inform you people latter, the problem is resolved..Thanks again for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •