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="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""
providerName="System.Data.EntityClient" />
</connectionStrings>
精彩评论