DLL中的SqlConnection对象在实例化时抛出"关键字不支持"异常

Nea*_*alR 3 c# sql dll connection-string

我写了一个用于连接SQL数据库的.dll.当它只是另一个Visual Studio项目中的类文件时,代码工作正常.但是,现在我试图在另一个中使用它作为.dll,这行抛出一个未处理的"ArgumentExcpetion":

        SqlConnection sqlConn = new SqlConnection(connString); 
Run Code Online (Sandbox Code Playgroud)

得到我的是异常消息框中的文本.

Keyword not supported: '<comp name>\sqlexpress;initial catalog'.
Run Code Online (Sandbox Code Playgroud)

这是我在另一个程序中用于连接到本地计算机上的SQL数据库的连接字符串.我在VS 2010中调试时可以查看"Locals"窗口,并且连接字符串看起来与我使用过的其他项目完全相同(实际上,我只是复制并粘贴它)

"<comp name>\\SQLEXPRESS;initial catalog=AgentResources;integrated security=True;MultipleActiveResultSets=true"
Run Code Online (Sandbox Code Playgroud)

以下是对象的实例化方式以及添加的连接字符串.

BatchRecord record = new BatchRecord("DEV", "TEST");

record.ConnString = "<comp name>\\SQLEXPRESS;initial catalog=AgentResources;integrated security=True;MultipleActiveResultSets=true";
Run Code Online (Sandbox Code Playgroud)

Blo*_*ard 5

该连接字符串无效.它应该是

 Data Source=<comp name>\\SQLEXPRESS;
Run Code Online (Sandbox Code Playgroud)