如何解决“来自外部数据库驱动程序(髰粑髫粑粑粑粑粑U)的意外错误”。而在sql中导出巨大的excel数据 [英] How to solve "Unexpected error from external database driver (髰粑��髫粑鮠粑)." while export huge excel data in sql

查看:69
本文介绍了如何解决“来自外部数据库驱动程序(髰粑髫粑粑粑粑粑U)的意外错误”。而在sql中导出巨大的excel数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

chkProc = 0;
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("" + pathss + "") + ";Extended Properties=Excel 12.0;Persist Security Info=False");
OleDbCommand ocmd = new OleDbCommand("select * from [" + sheetss + "$]", oconn);
oconn.Open();
OleDbDataReader odr = ocmd.ExecuteReader();





将大量数据从excel传输到sql server 2005时出现此错误发生在oconn open();



plz hlp me ...



this error occurs when transferring huge data from excel to sql server 2005 it occurs at the time of oconn open();

plz hlp me...

推荐答案

,oconn);
oconn。 Open ();
OleDbDataReader odr = ocmd.ExecuteReader();
", oconn); oconn.Open(); OleDbDataReader odr = ocmd.ExecuteReader();





将大数据从excel传输到sql server 2005时会出现此错误,它发生在oconn open();



plz hlp me ...



this error occurs when transferring huge data from excel to sql server 2005 it occurs at the time of oconn open();

plz hlp me...






使用以下代码并阅读来自EXCEL的数据并转换为数据集,然后执行将数据从数据集插入SQL Server数据库的过程。



Hi,

Use this below code and read the data from EXCEL and convert to Dataset and then do the process of inserting data from the Dataset to the SQL Server DataBase.

using System.Data.OleDb;
using System.IO;
using System.Data;


  private DataSet GenerateExcelData()
        {
            DataSet ds = new DataSet();
            try
            {
                string path = System.IO.Path.GetFullPath(Server.MapPath("Excel/InformationNew.xlsx"));
                if (Path.GetExtension(path) == ".xls")
                {
                    oledbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"");
                }
                else if (Path.GetExtension(path) == ".xlsx")
                {
                    oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");
                }
                oledbConn.Open();
                OleDbCommand cmd = new OleDbCommand(); ;
                OleDbDataAdapter oleda = new OleDbDataAdapter();
                cmd.Connection = oledbConn;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT * FROM [Sheet1


;
oleda = new OleDbDataAdapter(cmd);
oleda.Fill(ds,excelData);
返回ds;
}
catch(exception ex)
{
return ds;
}
最后
{
oledbConn.Close();
oledbConn.Dispose();
}
}
"; oleda = new OleDbDataAdapter(cmd); oleda.Fill(ds, "excelData"); return ds; } catch (Exception ex) { return ds; } finally { oledbConn.Close(); oledbConn.Dispose(); } }


这篇关于如何解决“来自外部数据库驱动程序(髰粑髫粑粑粑粑粑U)的意外错误”。而在sql中导出巨大的excel数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆