zoukankan
html css js c++ java
多种文件做数据源的连接方法
下面有详细方法:
http://www.connectionstrings.com/default.aspx
导入的文件下必须有一个命名为"
Schema.ini"的配置文件,如何配置,上面的网址里有详细说明.
如下示例:
string
dir
=
Path.GetDirectoryName(filePath);
string
filename
=
Path.GetFileName(filePath);
string
conStr
=
string
.Format(
"
Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\\;Extended Properties=\
"
text;HDR
=
Yes;FMT
=
Delimited(,)\
"
;
"
, dir);
using
(OleDbConnection oledbCon
=
new
OleDbConnection(conStr))
{
OleDbDataReader reader
=
null
;
OleDbCommand oledbCom
=
new
OleDbCommand();
oledbCom.Connection
=
oledbCon;
oledbCom.CommandText
=
string
.Format(
"
select top 1 * from {0}
"
, filename);
try
{
oledbCon.Open();
reader
=
oledbCom.ExecuteReader(); }
catch
(SqlException e)
{
throw
new
Exception(e.Message);
}
catch
(Exception ex)
{
throw
new
Exception(ex.Message);
}
finally
{
if
(reader
!=
null
)
{
reader.Close();
}
}
}
查看全文
相关阅读:
《Thinking In C#》
在图片上写字
在设计期跟踪代码
VS2003下的重构工具ReSharp
监视剪贴板的变化
一次重构导向设计模式的实践
JENA学习的零散笔记
jena处理Owl
Maven库中.lastUpdated文件自动清除工具
WEB数据挖掘(六)——Aperture数据抽取(2)
原文地址:https://www.cnblogs.com/wudingfeng/p/1086946.html
最新文章
常见路径使用方法
jq 学习资料
浏览器兼容文章
jquery UI datepicker时间控件的使用
Oracle常用命令
jquery 实现 点击按钮后倒计时效果,多用于实现发送手机验证码、邮箱验证码
Visual Studio 2005 ReportViewer 自适应报表大小显示(转)
WebConfig
解决ie6下png的透明背景问题
EasyUI DataGrid 时间格式化、字符串长度截取
热门文章
FusionCharts 使用经验
C# Timer用法及实例详解
.NET 基础知识点
样式问题总结
IE 兼容
数以亿计的数据记录优化查询(转)
收集了一些小技巧的连接
在窗体上查找控件
防止攻击的八个要点
VS.net 2005
Copyright © 2011-2022 走看看