ADO.NET操作Excel的连接字符串
2009-11-18 18:07
489 查看
private string GetConnectionString(string filePath)
{
if (filePath.EndsWith(".xls"))
return string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};"
+"Extended Properties='Excel 8.0;HDR=Yes;IMEX=2';", filePath);
if (filePath.EndsWith(".xlsx"))
return string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};"
+ "Extended Properties='Excel 12.0 Xml;HDR=YES';", filePath);
throw new Exception("wrong file type!");
}
{
if (filePath.EndsWith(".xls"))
return string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};"
+"Extended Properties='Excel 8.0;HDR=Yes;IMEX=2';", filePath);
if (filePath.EndsWith(".xlsx"))
return string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};"
+ "Extended Properties='Excel 12.0 Xml;HDR=YES';", filePath);
throw new Exception("wrong file type!");
}
相关文章推荐
- 利用ADO.NET连接Excel数据库,并执行相应的操作
- asp.net 操作Excel 连接字符串
- ado.net关于操作数据库的连接字符串整理
- ADO.net通过配置文件操作连接字符串
- ADO.NET连接字符串参考文档
- ADO.NET连接字符串
- C# ADO.net连接数据库 进行增删改查操作
- ADO.NET连接数据库字符串
- ADO.net_连接字符串
- ADO.NET连接数据库字符串
- ADO.NET 连接数据库字符串(Oracle、SqlServer、Access、ODBC)
- ADO.Net连接池和连接字符串剖析
- ADO.Net连接池和连接字符串剖析
- ADO.NET 3.5 Cookbook:一、连接数据(1)保存连接字符串
- ADO.NET连接数据库,及基本操作
- ADO.NET连接数据库字符串
- ADO.NET 用windows方式连接数据库以及简单的增,删,改,查询操作
- 轻松得到适用于C# ADO.NET的各种数据库连接字符串
- ADO.NET与SQL Server连接字符串
- ADO连接数据库字符串大全(VP,Excel,文本,Sybase,.NET等)