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

asp.net读取excl中的数据【转】

经常需要在数据库与Execl之间互导数据。net时代,ADO.NET可以使用使用Microsoft.Jet.OleDb访问访问Excel,网上已经有很多类似的资源,最典型也是最简单的可能如下:(asp.net环境)
 // 连接字符串           
        string xlsPath = Server.MapPath("~/app_data/somefile.xls"); // 绝对物理路径
        string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                        "Extended Properties=Excel 8.0;" +
                        "data source=" + xlsPath;
        // 查询语句
        string sql = "SELECT * from [Sheet1$]";
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(sql, connStr);
        da.Fill(ds);    // 填充DataSet       
       
        // 在这里对DataSet中的数据进行操作       
        // 输出,绑定数据
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
很简单吧?!一切就像操作数据库一样,只是需要注意的是:
1。数据提供程序使用Jet,同时需要指定Extended Properties 关键字设置 Excel 特定的属性,不同版本的Excel对应不同的属性值:用于 Extended Properties 值的有效 Excel 版本。
对于 Microsoft Excel 8.0 (97)、9.0 (2000) 和 10.0 (2002) 工作簿,请使用 Excel 8.0。
对于 Microsoft Excel 5.0 和 7.0 (95) 工作簿,请


相关文档:

asp.net C#网站项目 获取物理路径、虚拟路径的方法

-----------------------------.cs类文件中
当前项目的物理路径嘛:  
   
  strPath   =   this.Server.MapPath(Request.PhysicalApplicationPath);  
   
  你要说明什么“类文件”。任何PAGE、CONTROL代码也是在类 ......

asp.net 服务器端控件中 弹出对话框 操作

HTML代码:
<script language="javascript" event="onclick" for="ImageButton1">
 return confirm('确定要保存变更吗?');//返回false时不执行ImageButton1_Click方法,返回ture时执行ImageButton1_Click方法
</script> 
 <asp:ImageButton ID="ImageButton1" runat="server" ImageAlig ......

ASP.NET Mischellous II

@import url(“layout.css”)
CSS Selectors: *, p, div span, div > span, *[href], li+li, .title, #container, #title p:first-child, a:link, a:hover, a:visited, p:before, p:after
p:after{content:’url(images/quote.gif)’}
!important State Mode: Off, InProc, StateServer, SQLServer, C ......

ASP.NET中如何防范SQL注入式攻击

1将sql中使用的一些特殊符号,如' -- /* ; %等用Replace()过滤;
2限制文本框输入字符的长度;
3检查用户输入的合法性;客户端与服务器端都要执行,可以使用正则。
4使用带参数的SQL语句形式。 
ASP.NET中如何防范SQL注入式攻击 
 
一、什么是SQL注入式攻击?
  所谓SQL注入式攻击,就是攻击者把 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号