SQL Server connection string question [closed] - sql-server-2008

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this question
I'm trying to connect to a named SQL instance on the server.
There is already default instance of SQL Server 2005 and a newly named one - SQL Server 2008. I'm using the "Network library" property to use TCP connection but for some reason, he try's to connect the default instance and omit an error about login error.
If I remove the network library propery the connection established as well without any error.
I'm using windows authntication and have all the permissions needed.
The problematic connection string:
Data Source=ServerName\InstanceName,1433;network library=dbmssocn;Initial Catalog=MyDataBaseName;Integrated security=SSPI
The working connection string:
Data Source=ServerName\InstanceName;Initial Catalog=MyDataBaseName;Integrated security=SSPI
Omitting the ,1433;network library=dbmssocn from the connection string makes the difference. adding it maked the server to connect the deafult instance.
Both of the server allows remote connections.
I would like to understand why, please.
Thanks in advance,
Tamir

Copied from my answer on your question on ServerFault...
The connection strings have 2 differences so I'll try to answer for this...
Named instances do not listen on port 1433 (only the default instance by, er, default)
The instance name is ignored when the port is specified
So:
ServerName\InstanceName,1433 means connect to server "ServerName" on port 1433
ServerName\InstanceName means connect to server "ServerName" and resolve instance name to correct port (resolve uses port 1434 UDP)
However, network library=dbmssocn means use tcp. It could be the SQL Server instance (see port stuff) does not listen on tcp

At a guess the 2005 and 2008 instances would be listening on different ports. Perhaps you need to set the connection string for the SQL Server 2008 instance to the correct port; you could be hitting the SQL Server 2005 listener and asking it for an instance that is not present on the 2005 installation.
What port is the SQL Server 2008 instance listening on - This article discusses the subject. and has a powershell script that actually interrogates the system to find out what port the DBMS is really listening on. It also talks a little about where this config lives in the registry.

Related

cannot connect mysql server remote [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I cannot conect to Mysql server remotely, access granted to user from any host and mysql server is running. I can access locally using 127.0.0.1 but when I try to connect using machine's IP it gives me error "Can't connect to MySQL server on '192.168.1.102 (10060)'". I searched a lot couldn't sort this problem.
You shoudh check foll steps
MySQL is listening on public IP (sounds like you've done)
MySQL is listening on standard port / you're connecting the same port it's listening to.
Is there a firewall running on the remote machine? (They usually are packaged standard in distros) Is the firewall configured to allow connections to that port?
If the remote machine is within another network, is there network address translation (NAT) going on between your connection and the end machine - if so, is it configured to allow the MySQL port through.
Is the my.cnf file configured to allow connections from anything other than localhost 127.0.0.1 IPs - although you'd more likely get a access denied response, than a cannot connect.
please check your mysql config file, disable
bind-address = 127.0.0.1
first ping the server ip, if reply you can try this :
reconfigure mysql server instance , allow connect from remote machines

Connect to Mysql database from client using Mysql Connector [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to make connection between my database on the server,that located on the internet and my application that runs on some client.
My application based on .Net framework and i using MySql Connector for .Net component.
After some searches i gain the server address for the server by execute php command below :
echo $_SERVER['SERVER_ADDR'];
And this command returns : 67.225.166.81
I can connect to database with php when the php files runs on the server.
I used the values for connection in my .Net win app and this is the connection string :
string connStr = "server=67.225.166.81;port=3306;database=navayeme_joomfa;user id=navayeme;password=*****;";
The win app trying to make connection and an exception thrown :
Authentication to host '67.225.166.81' for user 'navayeme#myclientIP' failed ...
The myclientIP is ip of my client.
How can i fix this problem?Is possible the server doesn't support for this type of connection?
Using MySQL database together with a php script run on the same server does not mean that you can connect to the MySQL database from another network. PHP runs without a problem because it can make connection to the MySQL server on server using either
regular TCP connection (locally)
UNIX socket files
Please check that MySQL accepts connections on port 3306. If firewall is used, please make sure that 3306 is allowed for incoming connection.

Unable to login to SQL Server 2008 through command line utility [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have installed SQL Server 2008 Management Studio and am able to login to the database through this. I have also installed the SQL command utility. But, am unable to login through the command utility. I get the following error:
C:\Users\Administrator>sqlcmd
HResult 0x274D, Level 16, State 1
TCP Provider: No connection could be made because the target machine actively re
fused it.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A
network-related or in stance-specific error has occurred while
establishing a connection to SQL Server . Server is not found or not
accessible. Check if instance name is correct and i f SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online.. Sqlcmd: Error: Microsoft SQL Server Native
Client 10.0 : Login timeout expired.
I tried giving the server name, username and password explicitly using:
sqlcmd -S <hostname\database instance> -U <user> -P <pwd>
this too doesn't help.
I need this command utility for my automation stuff. Please help me!
At first blush, it sounds to me like your SQL Server Management Studio is connecting via a different network library, such as Named Pipes, while the sqlcmd client is attempting to connect via TCP, and the server isn't listening there (or perhaps on a non-standard port). That's why you're getting the TCP error in the latter instance.

Connection String for Remote Connections to SQL Server 2008

I am trying to connect remotely to SQL Server 2008 R2 Express on a server running Windows Server 2008 R2. I receive the following error:
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: TCP
Provider, error: 0 - A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond.)
I think the problem might be related to my connection string, because I am not sure exactly what it should be. I understand the connection string should take the form:
Data Source=123.123.123.123\InstanceName;Initial Catalog=MyDBName;user id=MyUserName;password=MyPassword;
The instance name of my SQL Server installation takes the form ComputerName\SQLEXPRESS. This is what I see when I log in to Management Studio on the server. So should the connection string begin with
Data Source=123.123.123.123\ComputerName\SQLEXPRESS
This looks wrong because of all the slashes. I have tried to omit the computer name thus:
Data Source=123.123.123.123\SQLEXPRESS
I also read somewhere that you can specify a port so I have also tried
Data Source=123.123.123.123,1433\SQLEXPRESS
because I understand that 1433 is the TCP port used by SQL Server and
Data Source=123.123.123.123,1434\SQLEXPRESS
because I understand that 1434 is the UDP port used by SQL Server browser.
I have also tried every combination of these and they all give the same error.
These are the steps I have taken to enable remote browsing on the server:
In Management Studio, right click the instance, go to Properties, Security and check SQL Server and Windows Authentication Mode. On the connections tab I have checked "Allow remote connections to this computer".
In SQL Server Configuration Manager I have enabled all four connection options (Shared Memory, Named Pipes, TCPIP and Via) under every node they occur. Under protocols for SQL Express I have tried specifying port 1433 and also leaving it blank with TCP Dynamic Ports set to 0 (which I think is meant to enable dynamic ports).
I have created firewall exceptions for TCP Port 1433, UDP Port 1434, and program exceptions for sqlservr.exe and sqlbrowser.exe.
If someone could tell me which of the four versions of the DataSource part of the connection string I should be using it would be a great help, even if it did not solve the problem. It would mean that everything I try subsequently I would only have to test once instead of four times.
Thanks in advance for any help!
Where did you enter the firewall exceptions, on your machine, on the server, or both?
The second connection string is the only really valid one. Can you telnet to the server on port 1433? Can you connect to the instance from Management Studio remotely and the problem is only from your code where the connection string is? Did you try running the same code on the server? Did you try forcing TCP/IP (vs. named pipes/shared memory etc) adding the following parameter to your connection string:
Network=DBMSSOCN;
This question comes up quite a lot and I'm sure you're hitting something that others have hit before. Have you gone through this article, "How to troubleshoot connecting to the SQL Server Database Engine"? Also there are 20+ questions on here that mention this error message and Express, according to this search result. I suggest double-checking your settings against some of the items in those answers that solved the issue for other users.

SQL Server connection string to a remote server

I have a remote SQL Server Express (2008 R2) with an IP: xx.xxx.xxx.xx and an instance name: myInstance.
I have been trying to connect to a DB (myDB) as user (dbUser) and with password (myPass).
I have tried various string combinations but none works. I am sure I got it wrong because the server is ok, I can ping the IP Address, SQL Server runs on port 1433, which is open. I have also enabled browser service and remote connection on the server.
Please someone give me the correct string...
How to: Configure Express to accept remote connections
There could be many reasons for this, however, you didn't post any useful details such as error messages or what exception was thrown (if any).
Check that Windows Firewall allows access on port 1433 - this is the most likely reason for the failure, since you are using an IP address and not the name of the instance.
I suggest looking at http://connectionstrings.com to check your connection string.