使用Azure存储时IErrorInfo.GetDescription失败,并显示E_FAIL(0x80004005)

时间:2018-12-27 14:56:40

标签: azure-storage linq-to-excel

我将Excel上传到Azure存储,并想将数据插入Microsoft Azure SQL数据库。但是我遇到了异常IErrorInfo.GetDescription失败,错误代码为E_FAIL(0x80004005)。

我已经在本地安装了Microsoft Access Database Engine 2010。

        try
        {
            var isUploadSuccess = string.Empty;
            var extension = string.Empty;

            if (excelUpload != null)
            {
                extension = Path.GetExtension(excelUpload.FileName);
                string fileName = DateTime.UtcNow.ToString("ddMMyyyyHHmmssfff") + extension;

                isUploadSuccess = AzureStorageHelper.UploadBlob(fileName, excelUpload, excelContainer);
            }

            if (!string.IsNullOrEmpty(isUploadSuccess) && isUploadSuccess != "-1")
            {
                var excelFile = new ExcelQueryFactory(isUploadSuccess);
                var accountDetails = from a in excelFile.Worksheet<MerchantBankAccountViewModel>() select a;
                var successRecord = 0;

                foreach (var acc in accountDetails)
                {
                    var result = db.AddMerchantBankAccountFromExcel(acc.AccountNumber, acc.MerchantName, acc.AccountHolderName, acc.ContactNumber, acc.BankName, acc.SwiftCode, acc.Branch, "", acc.Province, acc.City, acc.Country, acc.Zipcode, acc.IsSettlement.ToString(), acc.Remark);

                    if (result.Success)
                        successRecord += 1;
                }

                TempData["Success"] = successRecord + "/" + accountDetails.Count();
                return RedirectToAction("Index");
            }

            return View();
        }
        catch (Exception ex)
        {
            TempData["Alert"] = ex.Message;
            return View();
        }

我希望成功将excel中的数据插入到我的数据库中。 Excel Input

0 个答案:

没有答案