许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

列举系统安装的所有可用的数据库提供程序

示例:列举系统安装的所有可用的数据库提供程序

 

using System;
using System.Data;
using System.Data.Common;

 
namespace ConsoleWin
{
    
public class CmdWin
    {
        
public static void Main()
        {
            Console.WriteLine(
"Hello,This is a Console Line Applicaiton!");
            DataTable factoryClassesTable 
= DbProviderFactories.GetFactoryClasses();
            
foreach (DataRow factoryClass in factoryClassesTable.Rows)
            {
                Console.WriteLine(
"Name:\t\t" + factoryClass["Name"]);
                Console.WriteLine(
"Description:\t" + factoryClass["Description"]);
                Console.WriteLine(
"Invariant Name:\t" + factoryClass["invariantName"]);
                Console.WriteLine(
"\n");
            }
            Console.ReadKey();
        }
    }
}
/*
Hello,This is a Console Line Applicaiton!
Name:           Odbc Data Provider
Description:    .Net Framework Data Provider for Odbc
Invariant Name: System.Data.Odbc


Name:           OleDb Data Provider
Description:    .Net Framework Data Provider for OleDb
Invariant Name: System.Data.OleDb


Name:           OracleClient Data Provider
Description:    .Net Framework Data Provider for Oracle
Invariant Name: System.Data.OracleClient


Name:           SqlClient Data Provider
Description:    .Net Framework Data Provider for SqlServer
Invariant Name: System.Data.SqlClient


Name:           Microsoft SQL Server Compact Data Provider
Description:    .NET Framework Data Provider for Microsoft SQL Server Compact
Invariant Name: System.Data.SqlServerCe.3.5


Name:           SQLite Data Provider
Description:    .Net Framework Data Provider for SQLite
Invariant Name: System.Data.SQLite


Name:           MySQL Data Provider
Description:    .Net Framework Data Provider for MySQL
Invariant Name: MySql.Data.MySqlClient
*/

 

posted on 2011-03-06 01:12  许明会  阅读(264)  评论(0编辑  收藏  举报