English 中文(简体)
使用 asp.net 读取错误优于错误
原标题:Error reading excel using asp.net

在我的要求中,我成功地打开了 & amp; 阅读了 Asp. net OLEDB 提供的数据 Excel(2003 & amp; 07)。

但只有当 Excel Chelp Kept 在我们的 PC 中打开时, 它才有效, 否则它会给外部表格格式错误 。 究竟有什么问题??. 有人能给我看光吗? < strong> 这是否与访问权限有问题?

确定它与连接字符串无关。我的代码

protected void Page_Load(object sender, EventArgs e)
        {
            string path = @"C:UsersabcdDesktop
aj.xls";
            connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + absoluteDir + ";Extended Properties="Excel 8.0;HDR=YES;"";

            OleDbConnection oledbConn = new OleDbConnection(connStr);
            try
            {

                oledbConn.Open();
                OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
                OleDbDataAdapter oleda = new OleDbDataAdapter();
                oleda.SelectCommand = cmd;
                DataSet ds = new DataSet();
                oleda.Fill(ds);
                GridView1.DataSource = ds.Tables[0].DefaultView;
                GridView1.DataBind();
            }
            catch (Exception err)
            {

            }
            finally
            {
                // Close connection
                oledbConn.Close();
            } 
        }

提前感谢

最佳回答

问题在于访问问题... 暗号表被密码保护 。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!