开发者

Connecting ASP.NET MVC2 App to SQL Server

So I have a database running in SQL Server Management Studio.

The server information in the top of the Object Explorer says this:

(loc开发者_运维技巧al)(SQL Server 10.0.2531 - Scott-PC\Scott)

How do I connect my ASP.NET MVC2 App to this instance. 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.


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

check here for other options


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜