如何将ASP.NET Web应用程序连接到SQL Server [英] How to connect an asp.net web app to SQL Server

查看:53
本文介绍了如何将ASP.NET Web应用程序连接到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找方法上遇到了一些困难.我有一个正在创建的asp.net Web应用程序.我需要将其连接到SQL Server,以从几个表中提取数据.我已经找到了我认为正确的连接字符串,但是我不知道将它们放在何处以便可以在多个页面中使用它们?

I'm having some difficulty finding how to do this. I have an asp.net web app that I'm creating. I need to connect it to SQL Server to pull data from a couple of tables. I've found what I think are the correct connection strings, but I don't know where to put them so that I can use them for several pages?

我找到了这个连接字符串示例.

我需要知道的是将它放在哪里,以便可以在5-6个不同的页面上使用它?如果有人可以将我指向正确的方向,就足够了.

What I need to know is where do I put this so that I can use it on 5 - 6 different pages? If someone can point me in the right direction that would be enough.

推荐答案

在Visual Studio应用程序中应该有一个名为web.config的文件,它是一个XML文件.连接字符串位于

There should be a file called web.config in your Visual Studio application which is an XML file. The connection string goes in there under

<configuration>
    <ConnectionStrings>
         <add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=ServerName\InstanceName;Initial  Catalog=DatabaseName; Integrated Security=True; MultipleActiveResultSets=True" />
    </ConnectionStrings>
</configuration>

这篇关于如何将ASP.NET Web应用程序连接到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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