简体   繁体   English

将ASP.NET MVC2 App连接到SQL Server

[英]Connecting ASP.NET MVC2 App to SQL Server

So I have a database running in SQL Server Management Studio. 所以我有一个在SQL Server Management Studio中运行的数据库。

The server information in the top of the Object Explorer says this: 对象资源管理器顶部的服务器信息说明:

(local)(SQL Server 10.0.2531 - Scott-PC\\Scott) (本地)(SQL Server 10.0.2531-Scott-PC \\ Scott)

How do I connect my ASP.NET MVC2 App to this instance. 如何将我的ASP.NET MVC2应用程序连接到此实例。 I want a connection string in the web.config and then I want to be able to have a Database.cs class that performs all the stored proc and queries. 我希望在web.config中有一个连接字符串,然后希望有一个执行所有存储的proc和查询的Database.cs类。

Data Source=Scott-PC;Initial Catalog=DatabseName;User Id=Scott;Password=password;

在这里检查其他选项

Here is a sample... 这是一个示例...

<connectionStrings>
 <add name="ProductionServerEntities"
      connectionString="metadata=res://*/Models.MyDBEntityModel.csdl|res://*/Models.MyDBEntityModel.ssdl|res://*/Models.MyDBEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MYSQLSERVER;attachdbfilename=C:\inetpub\domains\MyDomainName\App_Data\MyDB03.mdf;Database=MyDB06;integrated security=False;User ID=sa;Password=MyPassword;multipleactiveresultsets=True;App=EntityFramework&quot;"
      providerName="System.Data.EntityClient" />
</connectionStrings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM