web中的连接字符串.配置连接失败

本文关键字:连接 配置 失败 字符串 web | 更新日期: 2023-09-27 18:06:49

我决定把我的项目从工作转移到家里,我在连接到数据库时遇到了一些麻烦。这个适用于work:

web . config:

  <connectionStrings>
    <add name="ApplicationServices" connectionString="Data Source=XXXXXX'SQLSERVER2008;Persist Security Info=true;Initial Catalog=esResearch;User ID=XXXXXX; Password=XXXXXX"
        providerName="System.Data.SqlClient" />
    <add name="esResearchConnectionString" connectionString="Data Source=XXXXXX'SQLSERVER2008;Initial Catalog=esResearch;Persist Security Info=True;User ID=XXXXXX;Password=XXXXXX"
        providerName="System.Data.SqlClient" />
  </connectionStrings>

app.config:

<connectionStrings>
    <add name="esResearchModels.Properties.Settings.esResearchConnectionString"
        connectionString="Data Source=XXXXXX'SQLSERVER2008;Initial Catalog=esResearch;Persist Security Info=True;User ID=XXXXXX"
        providerName="System.Data.SqlClient" />
    <add name="esResearchModels.Properties.Settings.esResearchConnectionString1"
        connectionString="Data Source=XXXXXX'SQLSERVER2008;Initial Catalog=esResearch;Persist Security Info=True;User ID=XXXXXX;Password=XXXXXX"
        providerName="System.Data.SqlClient" />
    <add name="esResearchModels.Properties.Settings.esResearchConnectionString2"
        connectionString="Data Source=XXXXXX'SQLSERVER2008;Initial Catalog=esResearch;User ID=XXXXXX;Password=XXXXXX"
        providerName="System.Data.SqlClient" />
</connectionStrings>

我想我不需要所有的字符串,但它至少工作。这一行在designer。cs

中使用
base(global::esResearchModels.Properties.Settings.Default.esResearchConnectionString2, mappingSource)

我已经在asp.net/mvc上完成了电影样本项目,并使用了这个connectionstring,这个在我家里的电脑上工作。

web . config:

  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.'SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
    <add name="MovieDBContext"
        connectionString="data source=.'SQLEXPRESS;Integrated Security=SSPI;database=Movies;User ID=sa;password=" 
         providerName="System.Data.SqlClient"/>
  </connectionStrings>

任何想法?

web中的连接字符串.配置连接失败

有这么多不同的连接字符串可用:

一般(Windows身份验证):

SqlConnection sql=new SqlConnection("Data Source=.''SQLEXPRESS;Initial Catalog=database;Integrated Security="True");

(身份验证状态"置疑"):

SqlConnection sql=new SqlConnection("Data Source=.''SQLEXPRESS;Uid=sa;password=sqlserver;database=databasename");

如果您想了解更多关于连接字符串的信息,请访问:

http://www.connectionstrings.com