<legend id='mylao'><style id='mylao'><dir id='mylao'><q id='mylao'></q></dir></style></legend>
    • <bdo id='mylao'></bdo><ul id='mylao'></ul>

      <small id='mylao'></small><noframes id='mylao'>

      <i id='mylao'><tr id='mylao'><dt id='mylao'><q id='mylao'><span id='mylao'><b id='mylao'><form id='mylao'><ins id='mylao'></ins><ul id='mylao'></ul><sub id='mylao'></sub></form><legend id='mylao'></legend><bdo id='mylao'><pre id='mylao'><center id='mylao'></center></pre></bdo></b><th id='mylao'></th></span></q></dt></tr></i><div id='mylao'><tfoot id='mylao'></tfoot><dl id='mylao'><fieldset id='mylao'></fieldset></dl></div>

      <tfoot id='mylao'></tfoot>
      1. 使用 C# 将 Excel 文件导入 Microsoft SQL Server

        Import Excel file into Microsoft SQL Server using C#(使用 C# 将 Excel 文件导入 Microsoft SQL Server)
        <tfoot id='XvMEN'></tfoot>
        • <bdo id='XvMEN'></bdo><ul id='XvMEN'></ul>

            <tbody id='XvMEN'></tbody>

            <legend id='XvMEN'><style id='XvMEN'><dir id='XvMEN'><q id='XvMEN'></q></dir></style></legend>

          • <small id='XvMEN'></small><noframes id='XvMEN'>

                  <i id='XvMEN'><tr id='XvMEN'><dt id='XvMEN'><q id='XvMEN'><span id='XvMEN'><b id='XvMEN'><form id='XvMEN'><ins id='XvMEN'></ins><ul id='XvMEN'></ul><sub id='XvMEN'></sub></form><legend id='XvMEN'></legend><bdo id='XvMEN'><pre id='XvMEN'><center id='XvMEN'></center></pre></bdo></b><th id='XvMEN'></th></span></q></dt></tr></i><div id='XvMEN'><tfoot id='XvMEN'></tfoot><dl id='XvMEN'><fieldset id='XvMEN'></fieldset></dl></div>
                  本文介绍了使用 C# 将 Excel 文件导入 Microsoft SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 C# 程序,我想将 Excel 文件导入 Microsoft SQL Server 2008 R2.

                  I have a C# program that I want to import an Excel file into Microsoft SQL Server 2008 R2.

                  谁能给我一个链接或教程,我可以完全理解如何做到这一点?

                  Can someone give me a link or tutorial where I can fully understand on how to this?

                  我已经做了很长时间了,我真的不知道如何实现它.

                  I've been doing this for a long time and I really don't have an idea on how to implement this.

                  请帮忙.谢谢.

                  推荐答案

                  string excelConnectionString = @"Provider=Microsoft 
                  .Jet.OLEDB.4.0;Data Source=Book1.xls;Extended 
                  Properties=""Excel 8.0;HDR=YES;"""; 
                  

                  //创建到 Excel 工作簿的连接

                  我们可以像这样将excel导入sql server

                  We can Import excel to sql server like this

                  使用(OleDbConnection 连接 =新的 OleDbConnection(excelConnectionString)){

                  OleDbCommand 命令 = 新的 OleDbCommand("Select ID,Data FROM [Data$]", 连接);

                  connection.Open(); 
                  
                  
                  `// Create DbDataReader to Data Worksheet `
                  using (DbDataReader dr = command.ExecuteReader()) 
                  { 
                      // SQL Server Connection String 
                      string sqlConnectionString = "Data Source=.; 
                         Initial Catalog=Test;Integrated Security=True"; 
                  
                  
                      // Bulk Copy to SQL Server 
                      using (SqlBulkCopy bulkCopy = 
                                 new SqlBulkCopy(sqlConnectionString)) 
                      { 
                          bulkCopy.DestinationTableName = "ExcelData"; 
                          bulkCopy.WriteToServer(dr); 
                      } 
                  

                  这篇关于使用 C# 将 Excel 文件导入 Microsoft SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                    <tbody id='obYgz'></tbody>

                  <small id='obYgz'></small><noframes id='obYgz'>

                        1. <legend id='obYgz'><style id='obYgz'><dir id='obYgz'><q id='obYgz'></q></dir></style></legend>
                          <tfoot id='obYgz'></tfoot>

                          <i id='obYgz'><tr id='obYgz'><dt id='obYgz'><q id='obYgz'><span id='obYgz'><b id='obYgz'><form id='obYgz'><ins id='obYgz'></ins><ul id='obYgz'></ul><sub id='obYgz'></sub></form><legend id='obYgz'></legend><bdo id='obYgz'><pre id='obYgz'><center id='obYgz'></center></pre></bdo></b><th id='obYgz'></th></span></q></dt></tr></i><div id='obYgz'><tfoot id='obYgz'></tfoot><dl id='obYgz'><fieldset id='obYgz'></fieldset></dl></div>

                          • <bdo id='obYgz'></bdo><ul id='obYgz'></ul>