我试图使用数据源属性来创建一个数据源,例如下面的例子:与数据源连接字符串属性到SQL Server
[TestMethod]
[DataSource("System.Data.SqlClient", "Data Source=.\\153.71.88.80;Database=LoadData_For_R10Core_10_5_Final_Extended;Integrated Security=True;Connect Timeout=30;User Instance=True", "Products", DataAccessMethod.Sequential)]
public void GetProducts()
{
}
但我不断收到错误:
The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
为了能够连接到SQL服务器,创建连接字符串的正确格式是什么。另外,我在该机器上有ODBC连接,所以如果有办法使用ODBC的连接,我会更喜欢这种方式。
我改变了连接字符串: [数据源( “System.Data.SqlClient的”, “数据源= 153.71.88.80;数据库= LoadData_For_R10Core_10_5_Final_Extended;集成安全性= TRUE;连接超时= 30;用户实例=真” ,“Products”,DataAccessMethod.Sequential)] 但是得到了完全相同的错误 –
您确定TCP/IP已启用吗?你可以连接SSMS吗? – SqlACID