简体   繁体   中英

Connection String for SQL Server Instance

I have SQL server 2000, and it have 2 other sql instances as well. Main sever has no issues, hereafter I am talking about those two instances,

They share,

  1. Same machine
  2. Same IP
  3. Same Instance Name
  4. Same Port

I too wonder how it has done.

Using query analyzer Once connect to,

MyServer\Invent (it connects to first instance)
MyServer\Invent,1433 (it connects to second instance)

(Yeah, it happens. I am 100% sure on that because I have separate DBs inside them)

Now it comes to problem,

With C# SqlConnection, I am unable to connect to first one, but can connect to second.

1. Data Source=MyServer\Invent;Persist Security Info=True;Initial Catalog=TEST;uid=admin;pwd=123
2. Data Source=MyServer\Invent,1433;Persist Security Info=True;Initial Catalog=TEST;uid=admin;pwd=123

Once I used 1st Connection String it hangs for a while and gets following error message...

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

Searched on net for this, many says installing such is possible. And one connection should use named pipes (tcp/445)

Any idea how to resolve this ? Any possible Connection String format ? Anyway of making Connection String for named pipes ?

I think maybe your first instance is not actually listening on 1433, even though that is usually the default.

I believe it's possible to change the default port with the SQL Server Configuration utility. Check what the default port is, and assuming it's not 1433, try specifying it in the first connection string.

Here's some info about how to check which port your instance is listening on.

Edit: Ok, the first instance is listening on a named pipe. Maybe server=np:MyServer\Invent; will work, as per this page .

I think your issue is that the one server is using a different port. So it's using TCP but a different port and you'll need to figure out what port is it using and then add that port to your connection string like you're doing with the other instance (1433).

you SQL Server configuration manager. Navigate to the SQL Server Network Configuration Node and expand it. Locate the instance in the children nodes Now on the right hand side you'll see Protocols (Shared Memory, Named Pipes, TCP etc.) Double Click on TCP. In the dialog that pops up, switch to the IP Address tab. Scroll all the way down to the "IP All" section

What does it say for TCP Port? 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM