介绍Excel导入sqlserver的方法
using System;
using System.Data;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//测试,将excel中的sheet1导入到sqlserver中
string connString = "server=localhost;uid=sa;pwd=sqlgis;database=master";
System.Windows.Forms.OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == DialogResult.OK)
{
TransferData(fd.FileName, "sheet1", connString);
}
}
public void TransferData(string excelFile, string sheetName, string connectionString)
{
DataSet ds = new DataSet();
try
{
//获取全部数据
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + excelFile + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn); conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
strExcel = string.Format("select * from [{0}$]", sheetName); myCommand = new OleDbDataAdapter(strExcel, strConn); myCommand.Fill(ds, sheetName);
//如果目标表不存在则创建
string strSql = string.Format("if object_id('{0}') is
如何高效的将excel导入s... 3页 2下载券 Excel导入SQLserver 25页 2下载券 ...将oledb读取的excel数据快速插入的sqlserver中,很多人通过循环来拼接sql,这样做不...
c#中高效的 excel 导入 sqlserver 的方法 中高效的时间:2010-02-26 15:15:53 来源:网络 作者:未知 点击:343 次 将 oledb 读取的 excel 数据快速插入的 ...
Excel导入SQLserver 25页 5财富值 excel导入到sqlserver 2页 20财富值 excel导入sqlserver 3页 5财富值 如何高效的将excel导入sql... 3页 5财富值 ...
如何高效的将 excel 导入到 oracle?和前两天的 SqlBulkCopy 导入到 sqlserver 对应,oracle 也有 自身的方法,只是稍微复杂些. 那就是使用 oracle 的 sql*loader ...
怎样把数据从excel2007导入到sqlserver2005_计算机软件及应用_IT/计算机_专业资料。本文介绍把excel数据导入到sql2005中怎样把信息从 怎样把信息从 Excel 表中导入数...
如何实现将 Excel 表 ( 含多张数据库表 ) 导入数据库 (SQLServer) _SQL ...c#中高效的excel导入sql... 3页 免费 c#中高效的excel导入sql... 2页 免费...
将Excel数据快速大批量导入数据库的代码_计算机软件及...Execute (sql) SQL Server 大部分人都知道用oledb...C#如何将Excel导入数据库... 3页 免费 将excel导入...
Excel 表数据导入 Sql Server 数据库中 By Aillo on November 21, 2008 2:...c#中高效的excel导入sql... 2页 免费 Excel表格数据导入到SQL... 暂无评价 ...
{ //测试,将excel中的sheet1导入到sqlserver中 string connString = "server=localhost;uid=sa;pwd=sqlgis;database=master"; System.Windows.Forms.OpenFileDialog...
C#把Excel导入数据库的两种方法_IT/计算机_专业资料。实现在c#中可高效的将excel数据导入到sqlserver数据库中,一种是循环将记录插入到数据库表中,最好的办法是使用...
热门文档