惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Spread Privacy
Spread Privacy
A
About on SuperTechFans
NISL@THU
NISL@THU
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
S
SegmentFault 最新的问题
G
Google Developers Blog
B
Blog
N
News and Events Feed by Topic
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
V2EX - 技术
V2EX - 技术
V
Visual Studio Blog
MyScale Blog
MyScale Blog
Webroot Blog
Webroot Blog
Vercel News
Vercel News
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
S
Security Affairs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
博客园 - 叶小钗
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Know Your Adversary
Know Your Adversary
T
Tailwind CSS Blog
F
Fortinet All Blogs
D
DataBreaches.Net
博客园 - Franky
博客园_首页
H
Heimdal Security Blog
宝玉的分享
宝玉的分享
阮一峰的网络日志
阮一峰的网络日志
Attack and Defense Labs
Attack and Defense Labs
Project Zero
Project Zero
雷峰网
雷峰网

博客园 - 北极熊,我来了!

C#获取类以及类下的方法(用于Asp.Net MVC) 使用JavaScript判断用户是否为手机设备 手机端页面自适应解决方案 Asp 邮件发送代码 js 日期字符串转换成日期类型,判断星期几 浅析a标签的4个伪类 C#读取Rss功能函数 《中文防止乱码的万能解决方案》 《小偷程序:自动获取百度天气预报》 Asp.NET使用HTML控件上传文件 《JS两级联动菜单学习全接触》 活动目录ADSI实现添加系统帐号问题!!! ADSI管理Windows2003系统帐号 中国频道空间使用Jmail发送邮件 《IP地址和数字之间转化的算法》 《单域名下整合动网、动易、OBlog程序》 JS读取XML数据 [XML系列]Flash读取XML数据 《省市联动功能菜单的实现》
Asp.NET读取Excel数据
北极熊,我来了! · 2007-04-14 · via 博客园 - 北极熊,我来了!

    有些时候数据导来导去挺麻烦的,之前做项目都习惯的要么是Access、Sql的,根本就没有想着要用Excel去做数据库,因为想想Excel软件去做数据库也不会专业到哪里去。这次是没辙了,之前做的东西是Sql数据库的,但是我们在外面根本就没有管理管理数据库的权限,郁闷死了。

     所以在给了我一堆的Excel文件之后,想都没有去想直接就考虑用Excel去使用数据库了,这样的查询一个嘛数据肯定是正确的,因为不用我们二次导入、二次手工输入,另一个嘛,管理也方便,直接复制黏贴下就可以的,不过后来发现有个问题,就是拿来做数据库的Excel文件好像会被锁定住,没有办法删除,呵呵,先不管这些了,东西效果先做出来先,反正也就用上一段时间就要撤下来的。

     以下是代码文件(其实跟之前的程序没有区别,这里记录下。):
string FilePath = "Data.xls";
OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(FilePath) + ";Extended Properties=Excel 8.0");
Conn.Open();
string Sql = "SELECT * FROM [Sheet1$] Where 准考证号码="20070415"";
OleDbCommand Command = new OleDbCommand(Sql, Conn);
OleDbDataReader Reader = Command.ExecuteReader();
if (Reader.Read())
{
Label1.Text = Reader[0].ToString();
Label2.Text = Reader[1].ToString();
}
Reader.Close();
Command.Dispose();
Conn.Close();
Conn.Dispose();

主要就是把驱动给换掉了,变成了,Extended Properties=Excel 8.0,其他的,SELECT * FROM [Sheet1$] 这里查询语句有点变化,[Sheet1$]这个是表的名称。