0

I have a issue, In my application I am trying to upload excel data using OLEDB connection. My code

                if (fileExtension == ".xls")
                {
                    connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                }
                else if (fileExtension == ".xlsx")
                {
                    connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                }

                //  Create OleDB Connection and OleDb Command

                OleDbConnection con = new OleDbConnection(connectionString);
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection = con;
                OleDbDataAdapter dAdapter = new OleDbDataAdapter(cmd);
                DataTable dtExcelRecords = new DataTable();


                con.Open();

is working fine when I am using

<identity impersonate="false"/>

But when I am using

<identity impersonate="true" userName="domain\accountname" password="*****"/>

The OLEDB connection throwing error, unspecified error.

Can someone please help me.

Thanks

Gulrej

4

1 回答 1

0

您可能希望提供有关您的解决方案的更多详细信息。模拟用户可能无权访问该文件。

模拟问题是多方面的,在不知道您的具体配置的情况下很难提供帮助。

当您在本地或远程访问服务器时也会发生故障。如果它在本地成功但在远程失败,您可能希望将 SPN 分配给您的应用程序的 ASP.NET 应用程序池用户帐户。

看看这篇文章

于 2013-05-22T05:53:54.137 回答