当前位置:编程学习 > C#/ASP.NET >>

E_FAIL(0x80004005)excel导入到数据库时出错,please!!!!

 if (File.Exists(filepath))
        {
            try
            {
                string strConn = "Provider=Microsoft.Jet.OleDb.4.0;" + "data source=" + @filepath + ";Extended Properties='Excel 8.0; HDR=YES; IMEX=1'";
                                
                OleDbConnection conn = new OleDbConnection(strConn);
                
                OleDbDataAdapter odda = new OleDbDataAdapter("select * from [" + SheetName + "$]", conn);

                DataSet ds = new DataSet();
                
                odda.Fill(ds);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    return (System.Data.DataTable)ds.Tables[0];
                }
                            }
            catch
            { }
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,