在ASP.NET中将连接字符串设置为SQL SERVER

问题描述:

我尝试在我的web.config文件(Visual Studio 2008 / ASP.NET 3.5)中设置一个连接字符串到本地服务器(SQL server 2008)。

I'm trying to set up a connecting string in my web.config file (Visual Studio 2008/ASP.NET 3.5) to a local server (SQL server 2008).

在我的web.config中,如何以及在哪里放置连接字符串?

In my web.config, how and where do I place the connection string?

,它更简单。您唯一需要设置的是YourDataBaseName。

You can also use this, it's simpler. The only thing you need to set is "YourDataBaseName".

  <connectionStrings>
    <add name="ConnStringDb1" connectionString="Data Source=localhost;Initial Catalog=YourDataBaseName;Integrated Security=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>