Connect LINQPad to remote SQL Server

僤鯓⒐⒋嵵緔 提交于 2019-12-21 03:42:44

问题


Disclaimer: I understand the question is very basic, but I could not find the answer in Google or here, and can not do it myself with guessed configuration.

I want to get started with LINQPad and I have a SQL Server 2005 installed on different machine in the same domain. But I can not connect to that server from LINQPad.

Here is the screenshot:

What do I put as a Server string?

Many thanks in advance!

Update 1: SERVERNAME\MSSQLSERVER does make a difference. Instead of Error

26 (Can not find server instance)

I get error

25 (Connection string is not correct)

I have tried 2 different SQL Servers: SQL 2005 on production server and Sql Server 2008 R2 on local machine, I have tried windows authentication and SQL authentication. And it makes no difference. But I can connect to both server (2005 and 2008) with MS SQL Server Management Studio with Windows and SQL server authentication. And it's not SQL Server permission issue - I have tried SA user to connect. It works with sqlservermanagementstudio, but not with LINQPad.

Any advice? Is there a setting on SQL Server I need to change?

Update 2: I found the solution to the problem. Into Server field I had to put SERVERNAME\ without specifying SQLEXPRESS or MSSQLSERVER.
Not very intuitive =(


回答1:


I found the solution to the problem. Into Server field I had to put "SERVERNAME\" without any SQLEXPRESS or MSSQLSERVER. Also as pointed out by @sgmoore, I could just type "LOCALHOST" or "SERVERNAME" and it connected. Apparently this is SQL Server feature/bug, nothing to do with LINQPad.

UPD You can also use "." to denote "localhost"




回答2:


You have to know the name of the computer you want and the name of the SQL-Server instance. For example, I have a computer named REB602, and, to use SQLEXPRESS on it (the SQL-Server instance that comes pre-installed with many versions of Visual Studio), then the string I type in is either REB602\SQLEXPRESS or .\SQLEXPRESS. The format is basically <computer-name> \ <instance-name>

I think the default instance-name for the full SQL-Server product is MSSQLSERVER, so if you don't know the name of the instance on the target computer, you can try that.

NOTE: it can take several tries to get a connection, because of the timeouts. I don't know if LinqPad lets you change the timeout -- I didn't see a way. When testing out my answer for you on computer REB602 this morning, I did "Test Connection" at the bottom of the LinqPad dialog box, got success, but the connection still timed out. I had to bring up SSMS (SQL-Server Management Studio, the IDE for SQL Server) to "warm up" my instance of SQLEXPRESS. After that, LinqPad worked like a dream. Don't give up on the first try :)



来源:https://stackoverflow.com/questions/7010735/connect-linqpad-to-remote-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!