How to detect Connection Type name from Connection string in .net

Is there new or existing method parse a connection string’s keys to determine the connection type (OleDbConnection, OdbcConnection, SqlConnection, MySqlConnection, DB2Connetrion, etc) ?

The result doesn’t meet to be the actual DbConnection, but either a string of the name or an enum of connection types parsed names.

For example if:

  • contains key “provider” it is OleDbConnection.
  • contains key “driver” it is OdbcConnection.

0 answers