简体   繁体   English

尝试在 Visual Studio 上连接到 SQL Server

[英]Trying to connect to SQL Server on Visual Studio

I have a little silly program to test a Connection to a database on SQL Server 2014, I'm using c# on Visual Studio 2015.我有一个愚蠢的程序来测试与 SQL Server 2014 上的数据库的连接,我在 Visual Studio 2015 上使用 c#。

First I tested it on my PC, it works wonderful!首先我在我的电脑上测试了它,它工作得很好! then I moved to my laptop.然后我搬到了我的笔记本电脑上。 I did a little mistake while installing SQL 2014 because I installed the manager before installing the other Express version... but when I created the database It worked so I thought it was not a problem.我在安装 SQL 2014 时犯了一个小错误,因为我在安装其他 Express 版本之前安装了管理器……但是当我创建数据库时它工作正常,所以我认为这不是问题。

But when I tested the connection in my laptop it fails!但是当我在笔记本电脑上测试连接时,它失败了! every time I try, I started all SQL services, I created an string connection but in the field where is supposed to be the name of the server it doesn't displays anything.每次尝试时,我都启动了所有 SQL 服务,创建了一个字符串连接,但在应该是服务器名称的字段中,它不显示任何内容。 So I tried using "."所以我尝试使用“。” as the name of the server and my database appeared, so I created the string connection and it says it is "connected".由于服务器和我的数据库的名称出现,所以我创建了字符串连接,它说它是“连接的”。

I'm really desperate because it works perfectly on my PC but on my laptop it just fails.我真的很绝望,因为它在我的 PC 上运行良好,但在我的笔记本电脑上却失败了。

Here is the code for the string, I have tested every name I see on SQL Server ( Julia, Julia-Fer, Julia\\Fer, even .\\SQLEXPRESS)这是字符串的代码,我测试了我在 SQL Server 上看到的每个名称(Julia、Julia-Fer、Julia\\Fer,甚至 .\\SQLEXPRESS)

System.Data.SqlClient.SqlConnection conn =
   new System.Data.SqlClient.SqlConnection();
        // TODO: Modify the connection string and include any
        // additional required properties for your database.
        conn.ConnectionString = "integrated security=SSPI;data source=.\\SQLEXPRESS;" +
 "persist security info=False;initial catalog=Proyecto";

I'm using Visual Studio 2012 on PC and 2015 on my laptop.我在 PC 上使用 Visual Studio 2012,在笔记本电脑上使用 2015。

将您的连接字符串更改为

conn.ConnectionString = "data source=.\\SQLEXPRESS;initial catalog=Proyecto;persist security info=False;integrated security=true";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到Visual Studio中的SQL Server - Unable to connect to SQL Server in Visual Studio 无法连接到 Visual Studio 中的 SQL Server - Cannot connect to SQL Server in Visual Studio connectionString问题。 使用Visual Studio 2013专业版。 尝试连接到SQL Server 2012上的员工数据库, - Issue with connectionString. Using Visual studio 2013 pro. trying to connect to employee DB on SQL Server 2012, 我正在尝试使用using(){} ..连接到SQL Server,但是我的Visual Studio显示以下错误: - I am trying to connect to SQL Server by using the using(){} .. but my Visual Studio shows the following error : 在尝试使用C#连接到Visual Studio 2010中的本地SQL Server数据库时遇到问题 - Having problems trying to connect to local SQL Server database in Visual Studio 2010 using C# 如何在SQL Server Management Studio中使用Visual Studio创建连接数据库? - How connect database created in SQL Server Management Studio with Visual Studio? 使用Visual Studio服务器资源管理器连接到远程SQL Server 2012 - Connect to remote SQL server 2012 using visual studio server explorer 无法将Visual Studio连接到SQL Server数据库 - Can't connect Visual Studio to SQL Server database 无法连接到Visual Studio 2012中的SQL Server - Can't connect to SQL Server in visual studio 2012 Visual Studio 2008无法连接到SQL Server 2008 - Visual Studio 2008 doesn't connect to SQL Server 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM