如何故障转移合作伙伴添加到连接字符串在VB.NET字符串、故障、合作伙伴、NET

2023-09-03 00:17:06 作者:这辈子丶唯你是从

我有一个Windows应用程序连接到数据库中读取一些数据。由于数据库是建立了韧性,我的应用程序需要连接到这两个数据库之一。有人可以指定哪些语法将使用SQL Server身份验证指定在连接字符串中的故障转移伙伴。

任何帮助是极大的AP preciated。

解决方案

检查 connectionstrings.com :

  

数据库镜像   如果您使用ADO.NET或SQL Native Client的到被镜像的数据库连接,应用程序可以利用驱动程序的能力优势,当一个数据库镜像故障转移时自动重定向连接。您必须指定在连接字符串中的初始主体服务器和数据库的故障转移伙伴服务器。

 数据源= myServerAddress,故障转移合作伙伴= myMirrorServerAddress;初始
目录= MyDatabase的;集成安全性= TRUE;
 

  

有ofcourse许多其他的方法来编写使用数据库镜像的连接字符串,这只是一个例子指出了故障转移功能。您可以使用其他连接字符串选项结合起来。

I have a windows application connecting to Database to read some data. Since the database is setup for resilience, my application needs to connect to one of the two databases. Can someone specify the what the syntax would be to specify the failover partner in a connection string using sql server authentication.

vb.net中连接数据库添加信息怎么弄 等待

Any help is greatly appreciated.

解决方案

Check connectionstrings.com:

Database mirroring If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial
Catalog=myDataBase;Integrated Security=True;

There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.