Im trying to develop a dotnet application with multiple database providers and i need to know the ConnectionString and Provider of the most used databases. Im i using System.DBCommon. This is my code:
public class DBConnector
{
public void ConectDatabase()
{
{
string connectionString =
"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" +
"(HOST=MYHOST)(PORT=1527))(CONNECT_DATA=(SID=MYSERVICE)));" +
"User Id=MYUSER;Password=MYPASS;"; //Connection String
string provider =
"Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess"; //I need this for the most used databases (Mysql, PostgreSQL, SqlServer)
using (DbConnection conn = (DbConnection)Activator.
CreateInstance(Type.GetType(provider), connectionString))
{
conn.Open();
string sql =
"select distinct owner from sys.all_objects order by owner";
using (DbCommand comm = conn.CreateCommand())
{
comm.CommandText = sql;
using (DbDataReader rdr = comm.ExecuteReader())
{
while (rdr.Read())
{
string owner = rdr.GetString(0);
Console.WriteLine("{0}", owner);
}
}
}
}
}
}
I found the connectionstrings in this site https://www.connectionstrings.com/
But i need the provider too. Thanks