Пример использования Provider Factory
DbDataReader rdr;
DbProviderFactory provider =
DbProviderFactories.GetFactory("System.Data.SqlClient");
using (DbConnection cn = provider.CreateConnection())
{
using (DbCommand cmd = provider.CreateCommand())
{
cmd.CommandText = "SELECT * FROM Sales.Customer";
cmd.Connection = cn;
cn.ConnectionString =
("SERVER= sql2005;INTEGRATED SECURITY=True;"
+ "DATABASE=AdventureWorks");
cn.Open();
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable("Product Locations");
dt.Load(rdr);
dataGridView1.DataSource = dt;
}
}
}