易截截图软件、单文件、免安装、纯绿色、仅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 Server 2005 Express 导入/导出数据(转)


SQL Server 2005 Express 导入/导出数据
安装好SQL Server 2005 Express后,再安装
http://download.microsoft.com/download/1/1/0/110d908f-c445-4523-b939-220c7d135f3d/SQLServer2005_SSMSEE.msi
就可以使用控制台进行数据库的管理。
但SQL Server Management Studio Express 并没有导入/导出数据的功能,我们可以 ......

【转】采用p6spy完整显示hibernate的SQL语句

作者:邱洋
QQ:1964477
    虽然在hibernate中有show_sql选项,但是显示出来的语句大多类似
    select * from xxx where value=?
    但是有时候我们需要得到完整的SQL语句,怎么办呢?使用P6SPY就可以完成这个任务
    p6spy是一个开源软件,它可以跟 ......

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

从csdn下载了使用案例,但发现很多人依然会遇到中文文件名乱码的问题,原因如下:
一般在单位的开发中在xml.config文件中都使用gb2312,如下:
  <globalization responseEncoding="gb2312" requestEncoding="gb2312"/>
而swfupload是按照utf-8来编码的,所以你需要在使用sufupload的程序文件目录下重新 ......

ASP.NET DBHelper类

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data.Common;
using System.Data;
namespace DownData.dal
{
    public static class DBHelper
    {
        private stati ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号