A connection string is a string consists of information needed to connect to a data store. It is passed via code to an underlying driver or provider in order to initiate the connection. It is commonly used to connect to a database, but you can also connect to a spreadsheet or text file using connection string and ADO.Net. The connection string may include attributes such as the name of the driver, server and database, as well as security information such as user name and password.
.NET Framework provides a set of data providers that serves as a bridge between an application and a data source. A data provider is used to retrieve data from a data source and to reconcile changes to that data back to the data source.
To connect to Oracle database, .Net Framework provides three main Data Providers: OracleClient Data Provider, OleDb Data Provider, and Odbc Data Provider. Each data provider uses different connection strings for different types of connections.
Below is given the list of connection strings used with different ADO.Net data providers to connect to Oracle database:
ADO.Net Data Provider | Connection Type | Connection String |
OracleClient Data Provider | Standard Security | Data Source= DatabaseServerName; User Id=myUsername; Password=myPassword; |
Trusted Connection | Data Source= DatabaseServerName; Integrated Security=Yes; | |
OLE DB Data Provider | Standard Security – Microsoft Driver | Driver=MSDAORA;Data Source=DatabaseServerName;User Id=myUsername;Password=myPassword; |
Standard Security – Oracle Driver | Driver=OraOLEDB.Oracle;Data Source=DatabaseServerName; User Id=myUsername;Password=myPassword; | |
Trusted Connection – Oracle Driver | Driver=OraOLEDB.Oracle;Data Source=DatabaseServerName; OSAuthent=1; OR Driver=OraOLEDB.Oracle;Data Source=DatabaseServerName; User Id=;Password=; | |
ODBC Data Provider | Using DSN | Dsn=DsnName; Uid=myUserName; Pwd=myPassword; |
Microsoft ODBC Driver | Driver={Microsoft ODBC for Oracle}; Server= DatabaseServerName.DatabaseName; Uid=myUserName; Pwd=myPassword; | |
Oracle ODBC Driver | Driver={Oracle ODBC Driver}; Dbq=DatabaseName; Uid=myUserName; Pwd=myPassword; |