using System;
using System.Data;
using System.Data.OleDb;
class Program
{
static void Main(string[] args)
{
string[] oledbConnectString = new string[]
{
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Category.xlsx;" +
"Extended Properties=\"Excel 12.0;HDR=YES\";",
"Provider=Microsoft.ACE.OLEDB.12.0;" +
@"Data Source=Category.xls;" +
"Extended Properties=\"Excel 8.0;HDR=YES\";"
};
foreach (string connectString in oledbConnectString)
{
OleDbConnection connection =new OleDbConnection(connectString);
connection.Open( );
Console.WriteLine("Connection.String = {0}\n",connectString);
Console.WriteLine("Connection.State = {0}",connection.State);
Console.WriteLine("Connection.Provider = {0}",connection.Provider);
Console.WriteLine("Connection.ServerVersion = {0}",connection.ServerVersion);
connection.Close( );
}
}
}
|