简体   繁体   中英

SQL Server 2012 connection issues in Visual Studio 2012 Server Explorer

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

在此处输入图片说明

You must have the correct connection string. I show the codes in 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);

The data connection string is located in yourdatabase.mdf file in connection string. you will see that in visual studio.

Update :

in server explorer right click on dataconnections then choose add connection. then select Microsoft SQL Server in server name use "." for your server name. then you can select your database or you can attach your database file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM