Client application use System.Data.SqlClient to connect always on read only site

Ashwan 536 Reputation points
2023-04-13T06:22:40.89+00:00

hi There we have SQL server 2016 SP3 enterprise two node SQL servers alwayson enabled secondary site available as read_only to access read only data. new application has been developed to connect to readonly using group listener . note :both nodes on same subnets Q1. What is the best method /improved drivers to connect readonly using read only routing Using System.Data.SqlClient or MSOLEDBSQL, OELDB or SQLNCLI Q2: What would be the connection string for System.Data.SqlClient data source=Listenenrname;database=DB;Integrated Security=SSPI;ApplicationIntent=ReadOnly; many thanks

SQL Server | Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.9K Reputation points MVP Volunteer Moderator
    2023-04-13T21:55:02.85+00:00

    Which client API you use largely depends on what the client is written in. For a client written in .NET, you would use SqlClient. For a native application written in C++, you would use the most recent ODBC driver. You would only use an OLE DB provider, if you already have an application that is using OLE DB. In that case you should use MSOLEDBSQL19 which is the most recent OLE DB provider. The connection string will be the same no matter the API, save for that keywords may vary. The above looks good, but give that there is some inconsistency with spacing, it is always good idea to look up a reference.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,586 Reputation points
    2023-04-14T01:56:25.2766667+00:00

    Hi @Ashwan,

    Agree with Erland. As for connection string, please refer to this:

    https://www.mssqltips.com/sqlservertip/7220/sql-server-connection-strings-reference-guide/

    Hope these would give you some help.

    Best regards,

    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.