易截截图软件、单文件、免安装、纯绿色、仅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 并没有导入/导出数据的功能,我们可以 ......

SQL语句复制表的方法


SQL语句复制表的方法
(2009-08-29 13:41:54)
标签:
sql
分类:计算机知识
如果目的表已经存在:
insert into DATAHR.DBO.GBITEM
select * from DEMO.DBO.GBITEM
如果目的表不存在:
select * into DATAHR.DBO.GBITEM
from DEMO.DBO.GBITEM
跨库导入
select * into [zk_news].[dbo].[News1] from [zk_media].[ ......

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

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

ASP.NET 文件上传

在ASP中,将文件上传到服务器是一件非常麻烦的事情,通常需要第三方组件的支持。
在ASP.NET 1.x 中,要支持文件上传,只须使用HTML的Input(File)控件。把它作为服务器控件运行(手动设置runat="server") ,要直接操作 HttpPostedFile。
在ASP.NET 2.0中,新增了FileUpLoad服务器控件,使得上传更加简单。
包& ......

ASP.NET数据库导入Excel

                StringWriter sw = new StringWriter();
                sw.WriteLine("访问购买率");
      &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号