0

I am trying to connect to SQL Server 2012 installed on Windows Server 2012 through Visual Studio 2012 but keep getting an error 25 connection string is not valid message when trying to connect through server explorer.

As far as I am aware it is sharing the same IP address as the main server. I am not connected to the domain but have checked that remote connections are enabled and port 1433. I can also connect to the main server.

I am new to SQL Server so any advice is greatly appreciated. Thanks

enter image description here

4

1 回答 1

0

您必须具有正确的连接字符串。我在 C# 中显示代码:

string con = @"Data Source=.\SQLEXPRESS;AttachDbFilename='c:\users\pc\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf';Integrated Security=True;User Instance=True";
        SqlConnection concect = new SqlConnection(con);

数据连接字符串位于连接字符串中的yourdatabase.mdf文件中。您将在视觉工作室中看到这一点。

更新 :

在服务器资源管理器中右键单击数据连接,然后选择添加连接。然后在服务器名称中选择 Microsoft SQL Server 使用“。” 为您的服务器名称。然后您可以选择您的数据库,也可以附加您的数据库文件。

于 2012-10-28T20:11:54.493 回答