SQL Server connection string problems

前端 未结 3 1421
没有蜡笔的小新
没有蜡笔的小新 2021-01-28 04:24

I am trying to have access to my project from the browser, I have put it on my server .

My database is on SQL Server 2008 R2 .

When I try to login I have always

相关标签:
3条回答
  • 2021-01-28 04:59

    The AttachDbFileName= feature is available ONLY in the SQL Server EXPRESS edition. It is NOT compatible and supported on a "full" SQL Server installation.

    If you have a full SQL Server, you have to attach your database to the SQL Server instance, and then reference it by its (logical) database name - not the physical file name:

    <connectionStrings>
      <add name="LocalSqlServer" 
           connectionString="server=.;database=DataUi;Integrated Security=SSPI;"
           providerName="System.Data.SqlClient" />
     </connectionStrings>
    
    0 讨论(0)
  • 2021-01-28 05:04

    I think there's a missing \\ in your AttachDBFilename right after |DataDirectory|:

    AttachDBFilename=|DataDirectory|\\DataUi.mdf
    
    0 讨论(0)
  • 2021-01-28 05:18

    You should "Database" rather than "AttachDbFileName" as it is not recommended for production servers.

    Hence your connection string should be:

    <connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Initial  
    Catalog=DataUi;Integrated Security=SSPI;Database=DataUi.mdf;User  
    Instance=true"
    providerName="System.Data.SqlClient" />
    </connectionStrings>
    
    0 讨论(0)
提交回复
热议问题