欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

从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();