ASP.NET: How to create a connection from a web.config ConnectionString?

后端 未结 3 766
Happy的楠姐
Happy的楠姐 2021-02-14 12:03

How do you construct a DbConnection based on a provider name?

Sample provider names

  • System.Data.SqlClient
  • System.Data.Ol
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 12:16

    If the providerName for the particular connection name (dev, test, prod) never changes why cant you do a switch on the connectionName param for your method and set the providerName instance that way?

提交回复
热议问题