How to add Failover Partner to a connection string in VB.NET

后端 未结 3 445
闹比i
闹比i 2020-12-10 08:52

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 database

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 09:27

    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.

提交回复
热议问题