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

ASP.NET Excel导入到SQL Server数据库


ASP.NET Excel导入到SQL Server数据库
提供把Excel里的数据导入到SQL Server 数据库,前提是Excel里的字段在Sql Server表里都有,不然会出现错误。注释很详细哦!要引用的命名空间是:
using System.Data.OleDb;
using System.Data.SqlClient;
//操作类
 public class ExcelToSQL
{
    //string SqlConnectionString = "Server=(local);Initial Catalog=Test;Integrated Security=True";
    public SqlConnection sqlcon;        //创建SQL连接
    public SqlCommand sqlcom;          //创建SQL命令对象
    public ExcelToSQL()
    {
        DataOperation dataOperation = new DataOperation(); //用到平台的函数,就是初始化SqlConnection对象
        DBUnit dbUnit = dataOperation.GetDbUnit();
        sqlcon = (SqlConnection)dbUnit.cnt;
        if (sqlcon.State.ToString() == "Open")
            sqlcon.Close();
    }
    public int ImportSql(string excelPath, string tableName)  //导入的Excel的路径,数据库里的表名
    {
        if (!TableExist(tableName)) //表名是否存在
            return (int)ImportState.tableNameError;
        DataTable dt = ExcelToDataTable(excelPath);
       if (dt == null)
        {
   &nbs


相关文档:

查询重复记录的SQL语句

SELECT tagid, tagname from uchome_mtag WHERE tagname IN (SELECT tagname from uchome_mtag GROUP BY tagname HAVING (COUNT(tagname) > 1)) ORDER BY tagname ......

三中SQL 分页方法效率分析

三种SQL分页法效率分析
表中主键必须为标识列,[ID] int IDENTITY (1,1)
1.分页方案一:(利用Not In和SELECT TOP分页)
 语句形式:利用Not In和SELECT TOP分页) 效率中,需要拼接SQL语句
  SELECT TOP 10 * from  TestTable WHERE (Id  NOT  IN (SELECT  TOP  20    id&n ......

找些不错的sql面试题(1)

Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
  select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
  fr ......

在asp.net中使用swfupload中,中文文件名乱码的解决

从csdn下载了使用案例,但发现很多人依然会遇到中文文件名乱码的问题,原因如下:
一般在单位的开发中在xml.config文件中都使用gb2312,如下:
  <globalization responseEncoding="gb2312" requestEncoding="gb2312"/>
而swfupload是按照utf-8来编码的,所以你需要在使用sufupload的程序文件目录下重新 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号