资源简介
本系统是没有经过数据库的系统,可以直接读取EXCEL文件的一类考试系统

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;
/**************
* 作者:李星
* 时间:2013-11-11
* 功能:知识竞赛系统(获取数据支撑类)
* ************/
namespace Exam
{
class DBHelper
{
//定义全局数据存储容器
static DataTable dt = null;
#region--获取基础数据--
///
/// 选择文件(目前没此需求)
///
private static string WriteExcel()
{
string filePath = ““;
try
{
//获取Excel文件路径和名称
OpenFileDialog odXls = new OpenFileDialog();
// 指定相应的打开文档的目录
odXls.InitialDirectory = “C://“;
// 设置文件格式
odXls.Filter = “Excel files (*.xls)|*.xls“;
odXls.FilterIndex = 2;
odXls.RestoreDirectory = true;
if (odXls.ShowDialog() == DialogResult.OK)
{
filePath = odXls.FileName;
}
}
catch (Exception Ex)
{
}
return filePath;
}
///
/// 显示数据
///
public static DataTable ShowTable()
{
//string fileName = WriteExcel();
string fileName = “tiku.xls“;
OleDbConnection ole = null;
OleDbDataAdapter da = null;
string strConn = “Provider=Microsoft.Jet.OLEDB.4.0;“
+ “Data Source=“ + fileName + “;“
+ “Extended Properties=Excel 5.0“;
string strExcel = “select * from [比赛$]“;
try
{
ole = new OleDbConnection(strConn);
ole.Open();
da = new OleDbDataAdapter(strExcel ole);
dt = new DataTable();
da.Fill(dt);
ole.Close();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
finally
{
if (ole != null)
ole.Close();
}
return dt;
}
#endregion
#region---把获取得到的数据放入DataTable---
public static DataTable GetQuestion(string name)
{
DataTable newdt = new DataTable();
if (dt != null)
{
newdt.Columns.Add(“Flag“ typeof(string));
newdt.Columns.Add(“Name“ typeof(string));
newdt.Columns.Add(“Item“ typeof(string));
newdt.Columns.Add(“Answer“ typeof(string));
foreach ( DataRow row in dt.Rows )
{
if (!row[“Flag“].ToString().Trim().Equals(““) && row[“Flag
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 29184 2013-11-14 13:51 Exam\bin\Debug\Exam.exe
文件 54784 2013-11-14 13:51 Exam\bin\Debug\Exam.pdb
文件 14328 2013-11-17 12:27 Exam\bin\Debug\Exam.vshost.exe
文件 490 2009-06-11 05:14 Exam\bin\Debug\Exam.vshost.exe.manifest
文件 31232 2013-11-12 08:19 Exam\bin\Debug\tiku.xls
文件 31232 2013-11-12 08:19 Exam\bin\Debug\tiku.xls~RF12f97b.TMP
文件 3866 2013-11-11 20:18 Exam\DBHelper.cs
......R 5056 2013-11-11 20:23 Exam\Exam.csproj
文件 257 2013-11-10 10:08 Exam\Exam.csproj.vspscc
文件 1605 2013-11-12 11:34 Exam\Exam.sln
..A..H. 22016 2013-11-17 12:29 Exam\Exam.suo
文件 256 2013-11-10 10:08 Exam\Exam.vssscc
......R 624 2013-11-10 08:46 Exam\frmBct.cs
......R 2344 2013-11-08 10:30 Exam\frmBct.Designer.cs
......R 5814 2013-11-08 10:30 Exam\frmBct.resx
......R 610 2013-11-10 08:47 Exam\frmRwt.cs
......R 2353 2013-11-08 10:30 Exam\frmRwt.Designer.cs
......R 5814 2013-11-08 10:30 Exam\frmRwt.resx
文件 3715 2013-11-11 11:18 Exam\frmXzt.cs
文件 14305 2013-11-11 11:18 Exam\frmXzt.Designer.cs
文件 11117 2013-11-11 11:18 Exam\frmXzt.resx
文件 9638 2013-11-14 13:51 Exam\Main.cs
文件 11558 2013-11-14 13:41 Exam\Main.Designer.cs
文件 6582 2013-11-14 13:41 Exam\Main.resx
文件 223 2013-11-12 08:21 Exam\mssccprj.scc
文件 510 2013-11-17 12:27 Exam\obj\Debug\Exam.csproj.FileListAbsolute.txt
文件 1023 2013-11-14 13:41 Exam\obj\Debug\Exam.csproj.GenerateResource.Cache
文件 29184 2013-11-14 13:51 Exam\obj\Debug\Exam.exe
文件 180 2013-11-14 13:41 Exam\obj\Debug\Exam.frmBct.resources
文件 180 2013-11-14 13:41 Exam\obj\Debug\Exam.frmRwt.resources
............此处省略25个文件信息
- 上一篇:c#自定义透明按钮控件
- 下一篇:WPF 环形菜单控件
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论