9 The SQL Server Data Provider : Provider Factories

Provider Factories
When you use the Common Programming Model, you do not need to specify the provider-specific namespace, because the Provider Factories generate instances of the specified data provider. The following C# code snippet obtains an instance of the SQL Server data provider:
DbProviderFactory factory = DbProviderFactories.GetFactory("DDTek.SQLServer");
DbConnection Conn = factory.createConnection();
Conn.ConnectionString = "Host=Accounting;Port=1433;User ID=test01;Password=test01;
Database Name=test");
 
try
{
    Conn.Open();
    Console.WriteLine("Connection successful!");
}
catch (Exception ex)
{
    // Connection failed
    Console.WriteLine(ex.Message);
}
// Close the connection
Conn.Close();