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();
}
}
}
查看全文
相关阅读:
前端路由hash、history原理及简单的实践下
nginx缓存配置及开启gzip压缩
koa2基于stream(流)进行文件上传和下载
理解nodejs中的stream(流)
理解http浏览器的协商缓存和强制缓存
Nginx中的Rewrite的重定向配置与实践
Redis入门---字符串类型
Redis报错 Server started, Redis version 3.2.13 Can't handle RDB format version 9 Fatal error loading the DB: Invalid argument. Exiting.
redis 基本原理及安装
Go语言之高级篇beego框架之Controller
原文地址:https://www.cnblogs.com/wudingfeng/p/1086946.html
最新文章
string.format格式化字符串中转义大括号“{}”
mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法
IIS7.5 错误代码0x8007007e HTTP 错误 500.19
finger-guessing game:3增加猜拳次数及猜拳按钮显示
lufylegend:Lbuttion等UI组件
finger-guessing game:2增加游戏进度,界面title及游戏界面
lufylegend:加载进度
finger-guessing game:1场景搭建
lufylegend:动画
.net连mysql数据库汇总
热门文章
Electron构建一个文件浏览器应用(一)
Electron实现第一个应用 "hello world"
在nginx上部署vue项目(history模式)--demo实列;
webpack4+koa2+vue 实现服务器端渲染(详解)
理解serverless无服务架构原理(一)
Performance --- 前端性能监控
nginx开启HSTS让浏览器强制跳转HTTPS访问
nginx配置SSL证书实现https服务
使用openssl 生成免费证书
Web安全之CSRF基本原理与实践
Copyright © 2011-2022 走看看