Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何在ASP/NETMVC中创建ConnectionString的数据源属性?_Sql Server_Asp.net Mvc 4_Connection String - Fatal编程技术网

Sql server 如何在ASP/NETMVC中创建ConnectionString的数据源属性?

Sql server 如何在ASP/NETMVC中创建ConnectionString的数据源属性?,sql-server,asp.net-mvc-4,connection-string,Sql Server,Asp.net Mvc 4,Connection String,我找不到一个像样的教程/博客可以解决我的问题 在我的笔记本电脑上,我运行一个名为“SQLServer”的Microsoft SQLServer。里面有一个叫做“SalesDB”的数据库。我不知道如何在ASP.NET MVC 4应用程序的web.config文件中填写ConnectionString的数据源属性,以使应用程序与数据库连接 这是默认的连接字符串: <connectionStrings> <add name="DefaultConnection" providerNa

我找不到一个像样的教程/博客可以解决我的问题

在我的笔记本电脑上,我运行一个名为“SQLServer”的Microsoft SQLServer。里面有一个叫做“SalesDB”的数据库。我不知道如何在ASP.NET MVC 4应用程序的web.config文件中填写ConnectionString的数据源属性,以使应用程序与数据库连接

这是默认的连接字符串:

<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Labo7SQL-20131226161445;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Labo7SQL-20131226161445.mdf" />

对于格式化连接字符串来说,它往往是非常有用的资源。对于MS SQL Server。例如:

Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

以最后一个为例,您的示例可能类似于:

Server=localhost\SQLSERVER;Database=SalesDB;User Id=myUsername;Password=myPassword;
对于格式化连接字符串来说,这是一个非常有用的资源。对于MS SQL Server。例如:

Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

以最后一个为例,您的示例可能类似于:

Server=localhost\SQLSERVER;Database=SalesDB;User Id=myUsername;Password=myPassword;

数据源
值应该是sql服务器的名称(或ip地址)。
Initial Catalog
值应该是数据库的名称…
SalesDB
并且您应该删除
AttachDBFilename

数据源值应该是sql服务器的名称(或ip地址)。
Initial Catalog
值应该是数据库的名称…
SalesDB
并且应该删除
AttachDBFilename