易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.net连接Excel

首先添加命名空间
using System.Data.OleDb;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
strfile = Request.QueryString["filename"];//从其他页面传过来的文件路径
Excel(strfile);
}
}

private void Excel(string filepath)
{
try
{
Dataset ds = new DataSet();
string ConnStr = "Provider=Microsoft.Jet.OleDb.4.0;data source=" + filepath +
";Extended Properties='Excel 8.0; HDR=YES; IMEX=1'";//连接Excel的字符串
string query = "SELECT * from [student$]";//Excel中的表名称
OleDbCommand oleCommand = new OleDbCommand(query, new OleDbConnection(ConnStr));
OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand);
oleAdapter.Fill(ds, "[student$]");
rowcount = ds.Tables[0].Rows.Count;
gridview1.DataSource = ds;
gridview1.DataBind();
lblmes.Text = "上传成功,数据如下所示,请确认:";//lblmes为label,显示提示信息
}
catch (OleDbException)
{
string filename = filepath.Substring(filepath.LastIndexOf('/') + 1);
lblmes.Text = "错误!请确认上传文件是否正确!当前上传的文件为:" + filename;
lbtnSure.Visible = false;
}
catch(Exception ee)
{
lblmes.Text = ee.Message;
}
}


相关文档:

ASP.NET 2.0缓存

一、页输出缓存
1.设置 ASP.NET
页缓存的两种方式
1.1
以声明方式设置 ASP.NET 页的缓存
以声明方式设置 ASP.NET
页的缓存的方法是在页中使用 @ OutputCache 指令,它的常用属性如下:
程序代码
<%@ OutputCache Duration="" VaryByParam=""
VaryByControl="" VaryByHeader ......

ASP.net Gridview 使用指南

GridView使用详解
 01 GridView无代码分页排序
 02 GridView选中,编辑,取消,删除
 03 GridView正反双向排序
 04 GridView和下拉菜单DropDownList结合
05 GridView和CheckBox结合
 06 鼠标移到GridView某一行时改变该行的背景色方法一
 07 鼠标移到GridView某一行时改变该行的背景 ......

Asp.NET获取文件及其路径


【相对路径】
Request.ApplicationPath
/src
Path.GetDirectoryName(HttpContext.Current.Request.RawUrl )
\\src\\Xiaoshe
Context.Request.Path
/src/Xiaoshe/Xiaoshe_New.aspx
Context.Request.CurrentExecutionFilePath
/src/Xiaoshe/Xiaoshe_New.aspx
Context.Request.FilePath
/src/Xiaoshe/Xiaoshe ......

asp.net利用jquery的ajax方法来验证登陆的代码

许多程序员在做业务开发时往往会在服务器端做用户信息的验证,有没有考虑过用jquery的ajax方法来验证登陆呢?且效果比在服务器端写代码来验证好的多,页面无刷新即可实现实现登陆验证,代码也简单。
现在下面贴出来的是很简单的用jquery的ajax方法来验证登陆的代码,适合刚接触jquery的朋友学习。
前台页面代码:
<he ......

ASP.NET 登录界面

//default.aspx.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Runtime.InteropService ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号