zoukankan
html css js c++ java
从Excel中读出导入sql server
/**/
///
<summary>
///
从Excel读取后导入sql server
///
</summary>
public
void
ReadExcel()
{
string
sql
=
"
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
"
+
Server.MapPath(
"
teachers.xls
"
)
+
"
;Extended Properties=Excel 8.0
"
;
OleDbConnection cnn
=
new
OleDbConnection(sql);
cnn.Open();
OleDbDataAdapter oda
=
new
OleDbDataAdapter(
"
select * from [教师$]
"
, cnn);
DataSet ds
=
new
DataSet();
oda.Fill(ds);
cnn.Close();
int
count
=
ds.Tables[
0
].Rows.Count;
for
(
int
i
=
0
; i
<
count; i
++
)
{
Jzgjbxx model
=
new
Jzgjbxx();
model.JZGID
=
ds.Tables[
0
].Rows[i][
"
JZGID
"
].ToString();
model.JZGBM
=
ds.Tables[
0
].Rows[i][
"
JZGBM
"
].ToString();
model.XXID
=
ds.Tables[
0
].Rows[i][
"
XXID
"
].ToString();
model.XM
=
ds.Tables[
0
].Rows[i][
"
XM
"
].ToString();
model.YHID
=
ds.Tables[
0
].Rows[i][
"
YHID
"
].ToString();
model.SFZH
=
ds.Tables[
0
].Rows[i][
"
SFZH
"
].ToString();
if
(ds.Tables[
0
].Rows[i][
"
CSRQ
"
].ToString()
!=
""
)
{
model.CSRQ
=
DateTime.Parse(ds.Tables[
0
].Rows[i][
"
CSRQ
"
].ToString());
}
else
{
model.CSRQ
=
DateTime.Now;
}
model.XBBM
=
ds.Tables[
0
].Rows[i][
"
XBBM
"
].ToString();
model.MZBM
=
ds.Tables[
0
].Rows[i][
"
MZBM
"
].ToString();
model.WHCDBM
=
ds.Tables[
0
].Rows[i][
"
WHCDBM
"
].ToString();
model.ZCBM
=
ds.Tables[
0
].Rows[i][
"
ZCBM
"
].ToString();
model.JSZGBM
=
ds.Tables[
0
].Rows[i][
"
JSZGBM
"
].ToString();
model.DYXLBM
=
ds.Tables[
0
].Rows[i][
"
DYXLBM
"
].ToString();
model.ZZMMBM
=
ds.Tables[
0
].Rows[i][
"
ZZMMBM
"
].ToString();
model.BZLBBM
=
ds.Tables[
0
].Rows[i][
"
BZLBBM
"
].ToString();
model.RKZKBM
=
ds.Tables[
0
].Rows[i][
"
RKZKBM
"
].ToString();
model.GWZYBM
=
ds.Tables[
0
].Rows[i][
"
GWZYBM
"
].ToString();
model.DZXX
=
ds.Tables[
0
].Rows[i][
"
DZXX
"
].ToString();
model.BZ
=
ds.Tables[
0
].Rows[i][
"
BZ
"
].ToString();
model.SCBZ
=
ds.Tables[
0
].Rows[i][
"
SCBZ
"
].ToString();
if
(ds.Tables[
0
].Rows[i][
"
CJNY
"
].ToString()
!=
""
)
{
model.CJRQ
=
DateTime.Parse(ds.Tables[
0
].Rows[i][
"
CJNY
"
].ToString());
}
else
{
model.CJRQ
=
DateTime.Now;
}
if
(ds.Tables[
0
].Rows[i][
"
CJGZNY
"
].ToString()
!=
""
)
{
model.CJGZRQ
=
DateTime.Parse(ds.Tables[
0
].Rows[i][
"
CJGZNY
"
].ToString());
}
else
{
model.CJGZRQ
=
DateTime.Now;
}
if
(ds.Tables[
0
].Rows[i][
"
LXNY
"
].ToString()
!=
""
)
{
model.LBXGZRQ
=
DateTime.Parse(ds.Tables[
0
].Rows[i][
"
LXNY
"
].ToString());
}
else
{
model.LBXGZRQ
=
DateTime.Now;
}
(
new
JzgjbxxBLL()).Create(model);
}
ds.Clear();
}
查看全文
相关阅读:
项目无法运行iPhone5模拟器
多线程下载图片,滑动tableView崩溃--资源抢夺问题
提醒事项 1. 冥想TX 2.下班路上听歌激励自己 3. 不戴眼镜 4. 困难任务拆解
AutoLayout性能不如frame
Tunnelblick 覆盖安装失败
weakSelf 和 strongSelf
动画
4/16 近期状态
知乎live 我的读书经验 总结
C语言-第23课
原文地址:https://www.cnblogs.com/wucf2004/p/823805.html
最新文章
SVProgressHUD使用
iOS10+xcode8真机测试的问题
xcode文件重命名
libz.1.2.5.dylib与libz.1.2.5.tbd
Android
初始面向对象-总结
面向对象进阶-反射、面向对象图式总结(一)
初识面向对象-封装、property装饰器、staticmathod(静态的方法)、classmethod(类方法) (五)
初识面向对象-接口类、抽象类、封装(设计模式)(四)
初识面向对象 -单继承、多继承(三)
热门文章
初识面向对象 -类和对象命名空间、组合用法(二)
初识面向对象-基础篇 (一)
初识面向对象
Spring定时任务的多种实现
Android:layout_weight的深度理解
could not write file .project
Android解析JASON方式
POST和GEST 数据限制方面的问题
使用PopupWindow和Activity两种不同的方式实现弹窗效果
CVP沙龙
Copyright © 2011-2022 走看看