无法连接到SQL Server在Visual Studio 2012 [英] Can't connect to SQL Server in visual studio 2012

查看:357
本文介绍了无法连接到SQL Server在Visual Studio 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到在Visual Studio 2012的SQL Server数据库,但没有运气。我有以下的code。

I am trying to connect to an SQL server database in visual studio 2012 but having no luck. I have the following code.

var db = Database.Open("anagram_database");
var shows_data = db.Query("SELECT * FROM sorted_words");

数据库名是没有任何错字的,我收到以下错误正确

the database name is correct without any typo's, I am receiving the following error

建立SQL Server的连接时发生网络相关的或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26 - 错误定位指定的服务器/实例)

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

我完全出我的深度这一点,甚至不知道从哪里开始。我似乎与Google找到任何东西。

I am completely out of my depth with this and don't even know where to start. I cant seem to find anything with googling.

推荐答案

从的文档

名称

类型:System

与数据库来打开相关联的名称。名称可以指定一个或.SDF数据库.MDF文件,是在App_Data文件夹中。 (不包括文件扩展名)。此外,名称可以指定在Web.config文件的连接字符串的名称。

The name associated with the database to open. name can specify an .sdf or .mdf database file that is in the App_Data folder. (Do not include the file-name extension.) Alternatively, name can specify the name of a connection string in the Web.config file.

下面,程序App_Data指登录用户的Application Data文件夹(或实际上,用户运行的应用程序,这可能是一样的)。键入%APPDATA%在Windows资源管理器的地址栏和preSS进入。打开该文件夹是你应该把 anagram_database.mdf 数据库文件。

Here, App_Data means the logged in user's Application Data folder (or actually, the user running the application, which is probably the same). Type %APPDATA% in the address field of a Windows Explorer and press enter. The folder that opens is where you should place the anagram_database.mdf database file.

这篇关于无法连接到SQL Server在Visual Studio 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆