class Program
{
static void Main(string[] args)
{
DbProviderFactory factory = DbProviderFactories.GetFactory(ConfigurationManager.ConnectionStrings["DB"].ProviderName);
DbConnection conn = factory.CreateConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
DbDataAdapter da = factory.CreateDataAdapter();
da.SelectCommand.CommandText = "Select * From table1";
da.SelectCommand.Connection = conn;
DataTable dt = new DataTable();
da.Fill(dt);
}
}
App.config檔
<?xml version="1.0" encoding="utf-8" ?>
沒有留言:
張貼留言