惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - .NET初学者俱乐部

给 .net C# 初学者几点建议 软件设计题视频教程下载,不错哟! 地球黑匣子,这个创意怎么样? 在实际开发中碰到的小问题,保存数据时提示:对象必须实现 IConvertible asp.net中使用ajax简单例子 asp.net 版 大学英语四六级、雅思、托福考试系统应用程序实例 spread 7.0 基础知识、程序示例、设置CheckBox、image 格式 C# 操作 Excel 与 C#操作 word 示例大全 asp.net 初学者应用程序示例网 公交车上的艳遇,那对被挤扁了..... 一个 .net 程序员的梦想!大哥们帮帮我好吗? 数据访问优化性能(转载) 全面优化ADO kinmax(转贴) 如何直接将.aspx页面直接生成静态页面.htm (转载) asp.net初学者 零起点 从入门到精通的网站! 再别康桥 --徐志摩 .NET打包工具怎么注册 .dll文件?? Excel导入SQL 自定义类 大数据量数据库转换程序写后感……
一个简单的EXCEL 导入SQL 的例子
.NET初学者俱乐部 · 2007-06-06 · via 博客园 - .NET初学者俱乐部

/// <summary>
  /// 操作EXCEL 到数据库
  /// </summary>
  private void OpterData()
  {
   if(txtExcelPath.Text.Trim()=="") return;

   string strSql=string.Empty;
   string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\";"+"data source=" + txtExcelPath.Text;
      
   strSql = "Select *  From [所学专业对应$]";//籍贯//新旧对应代码表-组织//新旧对应代码表-人员
   OleDbConnection  con1 = null;
   try
   {
    con1 = new OleDbConnection(connStr);
    OleDbDataAdapter pter1 = new OleDbDataAdapter(strSql,con1);
    con1.Open();
    DataTable dtb1 = new DataTable();
    DataSet ds = new DataSet();
    pter1.Fill(ds);
    dtb1=ds.Tables[0];

    SaveToSql cls1 = new SaveToSql();
    cls1.Server = txtServer.Text;
    cls1.DataBase = txtDataBase.Text;
    cls1.Uid = txtUid.Text;
    cls1.Pwd = txtPwd.Text;
    int i=0;
    progressBar1.Value =0;
    progressBar1.Maximum = dtb1.Rows.Count;
    foreach(DataRow drw in dtb1.Rows)
    {     
     cls1.strNewCodeId = drw[0].ToString();
     cls1.strNewCode = drw[1].ToString();
     cls1.strNewDes = drw[2].ToString();
     cls1.strOldCodeId = drw[3].ToString();
     cls1.strOldCode = drw[4].ToString();
     cls1.strOldDes = drw[5].ToString();
     cls1.TableNames = "GPMS_Code_Psn"; //目的表名
     cls1.Save();
     i++;
     progressBar1.Value=i;
    }
    MessageBox.Show("导入成功!");
    
   }
   catch(Exception Ex)
   {    
    MessageBox.Show(Ex.Message);
   }
   finally
   {
    con1.Dispose();
   }
  }