将数据从excel上传到数据库E_FAIL(0x80004005)时出错 [英] Error while uploading data from excel to database E_FAIL(0x80004005)

查看:485
本文介绍了将数据从excel上传到数据库E_FAIL(0x80004005)时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Web应用程序中上传excel文件,其显示错误消息为
E_FAIL(0x80004005),但是如果我在本地系统中调试应用程序,数据将上传到数据库.
我正在使用文件上传控件和按钮来上传数据.
代码如下所示
没有可用的错误消息,结果代码:E_FAIL(0x80004005).

I am trying uploading excel file in my web application its showing error message as
E_FAIL(0x80004005), but if i debug the application in my local system data gets uploaded to the database .
i am using file upload control and button to upload data.
code is shown below
No error message available, result code: E_FAIL(0x80004005).

//Reader to load content from Excel sheet
                   OleDbDataReader dReader;
                   excelConnection.Open();
                   dReader = cmdExcel.ExecuteReader();
                   SqlBulkCopy sqlBulk = new SqlBulkCopy(sqlcAdminConn);
                   //Give your Destination table name
                   sqlBulk.DestinationTableName = "admin.dbo.SwipeCardData";
                   sqlBulk.WriteToServer(dReader);
                   excelConnection.Close();
                   lblWarning.Text = "File Uploaded Successfully";
                   lblWarning.Visible = true

推荐答案

实际上,当您提交确定存储的数据时,您需要为此操作编写 SqlTransaction .请提供完整的代码,如果这是短代码的话.我可以为您提供完美的解决方案.
Actually, You need to write SqlTransaction for this operation when you commit data will definite store. Please provide full code, i this is small short of code. I can give you perfect solution for the same.


这篇关于将数据从excel上传到数据库E_FAIL(0x80004005)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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