在 ASP.NET 中设置连接字符串到 SQL SERVER [英] Setting up connection string in ASP.NET to SQL SERVER

查看:30
本文介绍了在 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?

以下是 web.config 文件现在的样子:http://imwired.net/aspnet/Online_web.config

Here's what web.config file looks like right now: http://imwired.net/aspnet/Online_web.config

推荐答案

你也可以用这个,更简单.您唯一需要设置的是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>

在哪里放置 连接字符串

<?xml version='1.0' encoding='utf-8'?>  
  <configuration>  
    <connectionStrings>  
      <clear />  
      <add name="Name"   
       providerName="System.Data.ProviderName"   
       connectionString="Valid Connection String;" />  
    </connectionStrings>  
  </configuration>  

这篇关于在 ASP.NET 中设置连接字符串到 SQL SERVER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆