利用 SqlbulkCopy ,将Excel数据导入数据库,代码显得非常简单。更重要的是,导入速度之快、超出预期想像。
本代码环境:VS2010、Excel2007、SqlServer 2008
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace ImportExcelintoSQLServer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{