开发者

i have a problem with connection string

开发者 https://www.devze.com 2023-03-08 06:47 出处:网络
An exception is thrown when i try to login: Cannot open database \"aspnetdb\" requested by the login. The login failed.

An exception is thrown when i try to login:

Cannot open database "aspnetdb" requested by the login. The login failed. Login failed for user 'DIMA-00AA1DA557\Dima'.

System.Data.SqlClient.SqlException: Cannot open database "aspnetdb" requested by the login. The login failed

My Web.config:

<system.web>
    <roleManager enabled="true" />    
    <membership defaultProvider="MyMembershipProvider">
        <providers>
            <clear/>
            <add
                name="MyMembershipProvider"    
                type="System.Web.Security.SqlMembershipProvider"      
                connectionStringName="LocalSqlServer"         
                requiresQu开发者_Go百科estionAndAnswer="false"      
                minRequiredPasswordLength="1"          
                minRequiredNonalphanumericCharacters="0"
                enablePasswordReset="true"
                maxInvalidPasswordAttempts="1000"
                passwordAttemptWindow="4000"
                enablePasswordRetrieval="true"
                requiresUniqueEmail="false"
                passwordFormat="Encrypted" 
            />         
        </providers>
    </membership>
</system.web>

My connection string section

<connectionStrings>
    <clear />
    <add name="LocalSqlServer"
        connectionString="Data Source=localhost;Integrated Security=SSPI; Initial Catalog=aspnetdb" />
        providerName="System.Data.SqlClient"
    <add name="YourGuruDB"
        connectionString="Data Source=DIMA-00AA1DA557;Initial Catalog=model;Integrated Security=True"/>
    <add name="modelConnectionString"
        connectionString="Data Source=DIMA-00AA1DA557;Initial Catalog=model;Integrated Security=True"
        providerName="System.Data.SqlClient"/>
    <add name="LocalSqlServer2"
        connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename='D:\Documents and Settings\Dima\My Documents\Visual Studio 2010\WebSites\WebSite10\App_Data\ASPNETDB.MDF';Integrated Security=True;User Instance=True"
        providerName="System.Data.SqlClient"/>
    <add name="MyLocalSQLServer"
        connectionString="Initial Catalog=aspnetdb;data source=localhost;Integrated Security=SSPI;" /> 
</connectionStrings>


You use windows authentication in web application. Web application use IIS account to run the code and it does not have enoght rights to open the db. There are two ways to fix the issue:

  1. Use sql server authentication
  2. Add rights to IIS user to work with db.
0

精彩评论

暂无评论...
验证码 换一张
取 消