易截截图软件、单文件、免安装、纯绿色、仅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语句复制表的方法


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].[ ......

SQL Server中索引

一、SQL Server中数据行的存储方式
     在SQL Server中存放数据的文件会以8KB的大小分页。每一页可以是数据、索引以及其他SQL Server数据库需要为其维护数据文件的数据类型。大多数页是数据页或索引页。页是SQL Server读、写数据文件的单元。每一页只包括一个对象的数据或索引信息,所以在每一个数据 ......

SQL output使用

SQL版:
alter proc testguo
(
    @cityid int,
    @cityname nvarchar(100) output
)
as
select @cityname =  city_name from BA_Hot_City where cityid = @cityid
select @cityname
go
declare @cityname nvarchar(100)
exec testguo 1,@cityname output
另一版:
ht ......

贺州市疾病预防控制中心SQL server数据库置疑成功修复

贺州市疾病预防控制中心所用的ZmSoft从业体检信息网络系统V2010.1.26 正式版采用SQL SERVER2000平台,不明原因,数据库"置疑“,客户试过所有网上方法,未能解决.沈阳凯文数据恢复中心SQL数据库工程师成功将其解决.
沈阳凯文数据恢复中心MS SQL SERVER研发小组致力于MsSql数据库技术的研究。经过多年研究完全掌握了S ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号