从ConnectionStringSettings获得数据库连接。使程序与具体数据库
程序员文章站
2022-05-31 22:26:58
...
//using System.Data; //using System.Data.Common; ConnectionStringSettings aSett = System.Configuration.ConfigurationManager.ConnectionStrings["configedDB"]; DbProviderFactory aF = DbProviderFactories.GetFactory(aSett.ProviderName); DbConne
//using System.Data;
//using System.Data.Common;
ConnectionStringSettings aSett = System.Configuration.ConfigurationManager.ConnectionStrings["configedDB"];
DbProviderFactory aF = DbProviderFactories.GetFactory(aSett.ProviderName);
DbConnection aconn = aF.CreateConnection();
aconn.Open();