Connect LINQPad to remote SQL Server - sql-server-2005

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

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"

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 :)

Related

Default server name for Microsoft SQL Server Management Studio 2012

I wanted to use Microsoft SQL Server and thereby installed a fresh copy of Microsoft SQL Server Management Studio 2012. It was an automatic installation and did not ask me for a server name. Right now, I'm stuck at the login screen and not sure what to put as the server name.
I happened to refer few previously posted questions and tried using ".\SQLExpress" as the Server Name, but the following error was displayed
What could be the possible Server Name ?
PS: The system name is "CBEUG".
SQL Management Studio is just that - the management studio tools. It is not the SQL Server itself. For that, you will need to install the SQL Server package.
If you can't see a SQL Server services in Services, it is not installed.
In the Server Name field (where you type the server name) you also have a scroll box with "Browse database..." (or something like that according to the version). That's where all of your databases are so you don't have to remember their names.
Good luck!
Well I was facing same issue and when i have done something like this
Server name : "your computer user name"\SQLExpress
and use your user name and password that you have given while installing the SQL studio.
it will work.
By default it takes the name of the computer
say if the computer name is B,then enter B as server's name with windows authentication

Microsoft OLE DB Provider for SQL Server error '80004005'

I have migrated a classic ASP site to a new server and am getting the following error, message.
I have tried different connection strings but none of them work.
I am not even sure if the connection string is the problem
The new server is a Windows 2012 Server, SQL Server 2008 R2 Express machine.
Microsoft OLE DB Provider for SQL Server error '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
/scripts/dbcode.asp, line 31
Application("C2M_ConnectionString") = "Provider=SQLNCLI10;Server=(local);Database=mysite_live;Uid=mysitec_Live;Pwd=mypass;"
If it is an Express instance, it is most likely not a default instance, but rather a named instance. So you probably meant:
... "Provider=SQLNCLI10;Server=.\SQLEXPRESS; ...
--- instead of just (local) ---^^^^^^^^^^^^
Otherwise you'll need to show us the server properties in SQL Server Configuration Manager on that machine in order for us to be able to tell you how to correct your connection string.
As Aaron Bertrand mentioned it would be interesting to have a look at your connection properties (In Sql Server configuration check if the following are enabled Name Pipes and TCP/Ip).
Since you're able to connect from SSMS i would ask to check if the Remote connection is allowed on that server Also can you tell is the Sql browser service is running?
here is a link that i keep close to me as a reminder or check list on probable connection issues on SQL Server.
Sql Connection Issues
And lastly can you try as provider "SQLNCLI" instead of "SQLNCLI10"
Step-1: Enabling TCP/IP Protocol
Start >> All Programs >> Microsoft SQL Server >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Network Configuration >> Protocols for MSSQLSERVER >> right click “TCP/IP” and select “Enable”.
Step-2: change specific machine name in Data Source attributes'value to (local) will resovle the problem ni SQL SERVER 2012.
Try pinging the server in your connection string. The server your application resides on should be able to communicate on the port you specify by credentials. If you are developing locally try specifying "localhost". If the server is clustered or you installed as an instance then you need to specify that instance. Also make sure the server is configured for mixed-mode authentication if using sql credentials.
OR Try
Data Source=localhost;Initial Catalog=DBNAME;Persist Security Info=True;User ID=MyUserName; Password=MyPassword;
It can be a permission issue , Please check is that server is connecting with same configuration detail from SQL management.
other is username / password is wrong.
Here is what I would do:
EDIT: Note that this SO post, a few down, has an interesting method for creating the correct connection string to use.
Open SSMS (Sql Server Management Studio) and copy/paste the
username/password. Don't type them, copy/paste. Verify there isn't
an issue.
Fire up the code (this is next for me b/c this would be the next
easiest thing to do in my case) and step to line 31 to verify that
everything is setup properly. Here is some info on how to do
this. I understand that this may be impossible for you with this
being on production so you might skip this step. If at all possible
though, I'd set this up on my local machine and verify that there is
no issue connecting locally. If I get this error locally, then I
have a better chance at fixing it.
Verify that Provider=SQLNCLI10 is installed on the production
server. I would follow this SO post, probably the answer posted
by gbn.
You have other working websites? Are any of them classic asp? Even
if not, I'd compare the connection string in another site to the one
that you are using here. Make sure there are no obvious differences.
Fire up SQL Server Profiler and start tracing. Connect to the site
and cause the error then go to profiler and see if it gives you an
additional error information.
If all of that fails, I would start going through this.
Sorry I can't just point to something and say, there's the problem!
Good luck!
Have you ever tried SQL Server OLE DB driver connection string:
"Provider=sqloledb;Data Source=(local);Initial Catalog=mysite_live;User Id=mysitec_Live;Password=mypass;"
or ODBC driver:
"Driver={SQL Server};Server=SERVERNAME;Trusted_Connection=no;Database=mysite_live;Uid=mysitec_Live;Pwd=mypass;"
At least this is what I would do if nothing helps. Maybe you will be able to get more useful error information.
Could this be a x86/x64 thing?
The following thread seems to indicate that the (local) alias is a 32-bit alias which fails on 64-bit server:
http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/c701d510-90e5-4dd0-b14f-ca1d694d6615
(note that the error is exacly what you had)
When you were testing the .udl on the server did you test both x86 and x64?
Following the advice from this blogpost (http://blogs.msdn.com/b/farukcelik/archive/2007/12/31/udl-test-on-a-64-bit-machine.aspx) you could test your
local udl :
in 64-bit by just double clicking it (acts the same as running "C:\Program Files\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
in 32-bit by double running C:\Windows\syswow64\rundll32.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
If you can confirm it's a problem with the alias I'd suggest you create a new one by following the guidelines found here:
http://msdn.microsoft.com/en-us/library/ms190445(v=sql.105).aspx
Have you tried to use the server IP address instead of the "(local)"?
Something like "Server=192.168.1.1;" (clearly you need to use the real IP address of your server)
In case you try to use the server IP address, check in the "SQL-Server configurator" that SQL Server is listening on the IP address you use in your connection. (SQL Server Configurator screenshot)
Other useful thing to check / try:
And check also if the DB is in the default SQL Server instance, or if it is in a named instance.
Do you have checked if the firewall have the TCP/IP rule for opening the port of you SQL Server?
Have you tried to connect to SQL Server using other software that use the TCP/IP connection?
The SQL Server Browser service is disabled by default on installation. I'd recommend that you enable and start it. For more information, see this link and the section titled "Using SQL Server Browser" for an explanation of why this might be your problem.
If you don't wish to enable the service, you can enable TCP/IP protocol (it's disabled by default), specify a static port number, and use 127.0.01,<port number> to identify the server.
In line 31:
cmd.ActiveConnection = Application("C2M_ConnectionString")
How are you instantiating cmd?
Rather than the ConnectionString being wrong, maybe cmd is acting differently in the new environment.
Edited to add:
I see that you've gone from IIS 7 to IIS 8. To run Classic ASP sites on IIS 7 required manual changes to server defaults, such as "allow parent paths." Is it possible that some of the needed tweaks didn't get migrated over?
If you're not running with Option Strict On, you should try that - it often reveals the source of subtle problems like this. (Of course, first you'll be forced to declare all your variables, which is very tedious with finished code.)

Cannot login to sql server 2008 R2 after rebooting server

I am using Windows-server-2008 with Microsoft SQL Server 2008.
And there are a lot of questions about this, but nothing on the internet solved it.
The problem is that i can't connect to the my SQL Server 2008 R2 after rebooting my server.
I placed some new memory in my server, and after rebooting my client/server application didn't work anymore because it cannot reach the database.
So i tried to get in SQL Server Management Studio (SSMS), and tried to loggin with Administrator and another user but both do not work.
When i logg in the following message is displayed:
Cannot connect to (local)
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 2)
I Tried a lot of different things like:
Rebooting server
Try to start the server manually from Sql Server Configuration Manager
Named Pipes - Enabled
TCP/IP - Enabled
Tried to create an new system user or database user as described in the following article: Click Here
Can somebody please help me? I am really confused because i need to get this online. Otherwise i have to reinstall the database server but i do not have a back-up. (is there some folder with a back-up of the settings/tables/columns are stored and can be imported from reinstall?
I was having the exact same problem. net start mssqlserver was giving me the blurb about a failed login attempt. The problem was that I had recently changed the password for the administrator account, and the new password didn't get updated in services.
Here's how I fixed it:
First locate SQL Server from the list here:
Right click and select properties, and navigate to the Log On tab:
Then I typed the new password, and like magic I was able to start SQL Server right through the services manager.
I also did this for any other processes which were marked as "stopped" even though Startup Type was marked as "automatic" (namely, SQL Server Agent).
Is it a named instance or default? Also, is this a local instance? (I see the "(local)" but just wanted to make sure.)
Start the sql server services from services.msc and try to connect

SQL Server 2008 R2 First Time Login

I've just started work on a new computer in which I had to download all the software fresh.
I've just download a copy of SQL Server 2008 R2, and I'm trying to connect to SQL Server Management Studio without success. I vaguely remember last time I installed this, it asked me to choose between windows, or sql server authentication, however this didn't happen for this installation.
If I try to login via Windows Authentication (where the username and password fields are greyed out, localhost as server name) it gives the following error:
"A Network-related or instance
specific error occured 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: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server) (Microsoft
SQL Server, Error: 2)"
I have checked everything in SQL Server Configuration Manager, and everything bar VIA is enabled.
If I try SQL Server Authentication, It asks me for a username and password which I definiately have not set yet. Also, under SQL Server Services in configuration manager, there is nothing there.
Any help would be appreciated :)
Thanks
PS: I don't know if it's worth mentioning but I am running Windows 7 as a virtual machine on a Mac.
Are you sure you have the correct instance name? If it was SQL Server 2008 R2 Express Edition then the default instance name is .\SQLEXPRESS.
Also if your using sql authentication to connect try running sql management studio as admin, if you are a limited user your identity might not be mapped to an account in sql server yet but i believe the Administrators user group is.
You need to check if your services are running.
Please type
net start mssqlserver
in your command prompt. Then try to login.
Ended up reinstalling completely and doing a fresh install from a fresh download. When I did this I was brought through the steps of selecting the default instance, and selecting authentication modes.
Working fine now :)
After checking tons of sites looking for an answer to this question, I think I have a simple solution.
Open the sql Server Configuration
Click on the sql server services node
Right Click on Sql server
Click Start.
I have been screwing around with this forever, and this simple method actually worked.

Can't establish SQL Server connection from VS 2008

I am sorry if this sounds like a silly question, but I have googled for a while for a solution and no success. I am trying to establish a connection from VS 2008 to SQL Server. I am trying to use an user that my web application has been successfuly using to access the database from in its connection string. But when doing it from VS 2008, it tells me "Login failed for use 'xxxxxx'". I am currently in the "Add Connection" window. I have chosen the datasource and server name, fulfilled username and password for SQL Server Authentication. Do I have to set specific permissions for this user? Do I need to allow a VS 2008 user in SQL Server? Thanks.
I have found the solution for this problem. My Visual Studio would pull automatically something like MACHINENAME\SQLEXPRESS. As it was pulled automatically, I did not bother taking a closer look at it. I finally realized the connection string that worked for me in my other application was .\SQLESXPRESS. When I entered it in Visual Studio, it did work. Thank you all for the help.
Do you have SQL Server Management Studio Express Installed? if so try connecting as the same user through that interface. This will isolate your problem a bit.
With Visual Studio, you're connecting through a "remote" connection, even though they're on the same machine. With Server Management Studio, you're connecting through a named pipe probably. You need to change the SQL configuration so that it allows remote connections. Here are instructions for how to do it.
You can test your SQL connection by connecting using LINQPad, Often find this solves problems with connections to new SQL Server instances at my workplace.
http://www.linqpad.net/
Are you trying to specify the username and password to connect with in the connection string - ALA:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
This actually uses SQL Authentication, not Integrated (Windows) authentication. What you might be looking for is this:
Data Source=myServerAddress;Initial Catalog=myDataBase;Trusted_Connection=True;
This would log into the database as the use running Visual Studio. Notice that the username/password aren't specified here - it uses the current Windows identity - in your case, that's the user running Visual Studio.