14

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: Fail to connect

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 , 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 =(

Cœur
  • 37,241
  • 25
  • 195
  • 267
trailmax
  • 34,305
  • 22
  • 140
  • 234

2 Answers2

10

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" enter image description here

trailmax
  • 34,305
  • 22
  • 140
  • 234
  • 1
    Excellent! If it's any comfort, I had a very similar issue when trying to connect to SQL Server from Mathematica, and it took maximum escalation at Wolfram Research to get it figured out. The fundamental problem is that there are so many ways to stitch together a connection string from substrings typed into dialog-box type-in fields or otherwise. With or without backslashes, doubled backslashes, idiosyncratic quoting chars, and all the rest. Glad you got it! – Reb.Cabin Aug 11 '11 at 03:25
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 :)

Reb.Cabin
  • 5,426
  • 3
  • 35
  • 64
  • A! I was missing MS from MSSQLSERVER. However, now I'm getting different error: authentication error. But this is other problem. I'm trying to connect to a dev database on production server, so it should be up to speed already -).. Thanks! – trailmax Aug 10 '11 at 13:05