Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2006, 04:48 AM
Authorized User
 
Join Date: May 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excell to Datagrid in asp.net

Hello Friends,
I am retrieving Data from Excell sheet to my Datagrid in ASP.Net Page
The is given below.But It is giving an unspecified error.
Can anyone tell me the sloution.


string connection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\ExcelData.xls;Extended Properties=Excel 8.0";
            string connection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\Book2.xls";
            OleDbConnection con=new OleDbConnection(connection);
            OleDbDataAdapter da=new OleDbDataAdapter("select * from [Sheet1$]",con);
            DataSet ds=new DataSet();
            da.Fill(ds,"XLData");
            DataGrid1.DataSource=ds.Tables["XLData"].DefaultView;
            DataGrid1.DataBind();

rajkumar sharma
__________________
-------------------
rajkumar sharma
http://www.apnasaathi.blogspot.com
 
Old May 20th, 2006, 10:10 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

http://support.microsoft.com/?kbid=306572

 
Old May 22nd, 2006, 05:50 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Hi,

Please notice :
/********************************/
string connection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\ExcelData.xls;Extended Properties=Excel 8.0";
            string connection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\Book2.xls";

/********************************/

The first connection string is more accurate than the second one [exctended properties] in case of Excel

Can you that this is not creating a problem for you. moreover same variable is being initialized twice in this code. I believe this should throw the compile time error.

Anubhav Kumar
 
Old May 22nd, 2006, 06:00 AM
Authorized User
 
Join Date: May 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks anubhav ,
But I have written only one connection string and i had tried with both the given connection strings one by one but Error comes out which is

"Unspecified error" at adapters fill statement.

rajkumar sharma





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create an excell chart with ASP tiahvera Classic ASP Databases 1 August 3rd, 2007 06:39 PM
vb.net asp.net DataGrid krantips VS.NET 2002/2003 0 June 28th, 2006 01:22 AM
Save Datagrid in a Excell format thomaz C# 6 February 24th, 2006 12:53 AM
ASP.NET datagrid marclena VS.NET 2002/2003 2 November 4th, 2003 11:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.