views:

1494

answers:

2

Hello everyone,

Could anyone point me or tell me how to write connection string to a SQL Server cluster instance? I want to establish trusted connection to a database (initial catalog) of the specific instance of SQL Server cluster. I find for quite some time but can not find official answer from Google.

BTW: I am asking for the connection string for C# ADO.Net code.

thanks in advance, George

EDIT1: I know how to write connection string to a normal one-machine non-cluster SQL Server instance.

+2  A: 

The server name is the virtual server name.

eg physical pserver1, pserver2 together make cluster cserver which hosts virtual servers vserv1 (and perhaps) vserv2

So, it's vserv1\instancename or vserv1

Edit, based on number of possible names for virtual servers:

The cluster may be active/passive or active/active.

In A/P, only one virtual server is hosted and the standby node is not actively used.

In A/A, there are 2 virtual servers and normally each node hosts one. Each node is standby for the other.

gbn
Confused -- "hosts virtual servers vserv1 (and perhaps) vserv2", do you mean the cluster has two virtual server name, vserv1 and vserv2? Or it is a typo?
George2
what is the connection string format of SQL cluster non-default instance?
George2
vserv1\instancename (or vserv2\instancenamein A/A scenarios
gbn
+1  A: 

The connection string is written in the usual way; but in clustering you have 3 (or more) addresses: one for each node which constitues the cluster and one for the cluster. E.g.: we have two node with addresses 192.168.0.10 and 192.168.0.20: if you write down one of this numbers as the DataSource in the connection string, you'll gain access to that physical instance. But if you want to access the cluster (virtual) Sql Server instance, you'll have to use the cluster's address (e.g.: 192.168.0.230) as the DataSource. Of course, you can also use the machines' names instead of the IP addresses, provided you are in the same domain as the cluster.

Turro
Using machine names does not depend on being in the same domain, only on the names being exposed in DNS. And having a rational DNS configuration: this might be a problem in some organisation :-(.
Richard
You're right; i was focusing on the connection string and missed this point, sorry.
Turro
@Turro, 1. what is the connection string format of SQL cluster non-default instance? 2. For a SQL cluster, do we allow to connect by machine name to access individual machine instead of virtual server name? Does such access corrupt data mirroring between two virtual nodes?
George2
@Richard, what is the problem do you mean?
George2
@George2: 1) the connection string is always the same, you just have to specify in the DataSource=xxx the name of the instance you want to access; e.g.: Password=pwd;Persist Security Info=True;User ID=userid;Initial Catalog=dbname;Data Source=THENAMEORTHEIPADDRESSOFTHEINSTANCE;
Turro
@George2: 2) I would not use the individual instances; actually I don't know if you run the risk of corrupting the data, but for sure you loose the benefit of the cluster. That is, if the "master" instance is down (for whatever reason) and you are accessing the default cluster, your connection will trasparently switch to the other (which has becoma active) without any intervention. But if you are accessing the individual instance and this is down, your application will not be able to access it; is it worth to have a cluster and not to use it? Maybe, but *I* wouldn't do that
Turro
@George2: I'm just guessing Richard thoughts, but perhaps he referred to the fact that some organizations could lack the skills to mantain a DNS configuration. Or at least, this has been the case for some of my custmers in the past...
Turro