473,503 Members | 1,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading data from excel using OLEDB

I read an article on the link:
http://support.microsoft.com/default...b;en-us;306572 related to
reading data from Excel using OLEDB The topic's heading is: How to query and
display excel data by using ASP.NET, ADO.NET, and Visual C# .NET
I am trying with the same code in Visual Studio 2005 in ASP.NET application.
The code i am using is:
protected void Page_Load(object sender, EventArgs e)
{

String connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\ExcelData.xls;Extended Properties=Excel 8.0;";
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM myrange1", con);

OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "XLData");
//da.Fill(ds, "ExcelData");
GridView1.DataSource = ds.Tables[0].DefaultView;
//GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();

}
I have included name space:using System.Data.OleDb;
The problem is when i execute the application following exception is coming:
The Microsoft Jet database engine could not find the object 'myrange1'.
Make sure the object exists and that you spell its name and the path name
correctly.
I have followed the same steps while creating Excel file and have given the
same names but still having the problem Please help..

Oct 28 '08 #1
1 10384

Try
[range1$]

When googling, search for
[Sheet1$]

which is the most common example type syntax

"Shees Abidi" <Shees Ab***@discussions.microsoft.comwrote in message
news:BE**********************************@microsof t.com...
>I read an article on the link:
http://support.microsoft.com/default...b;en-us;306572 related to
reading data from Excel using OLEDB The topic's heading is: How to query
and
display excel data by using ASP.NET, ADO.NET, and Visual C# .NET
I am trying with the same code in Visual Studio 2005 in ASP.NET
application.
The code i am using is:
protected void Page_Load(object sender, EventArgs e)
{

String connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\ExcelData.xls;Extended Properties=Excel 8.0;";
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM myrange1", con);

OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "XLData");
//da.Fill(ds, "ExcelData");
GridView1.DataSource = ds.Tables[0].DefaultView;
//GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();

}
I have included name space:using System.Data.OleDb;
The problem is when i execute the application following exception is
coming:
The Microsoft Jet database engine could not find the object 'myrange1'.
Make sure the object exists and that you spell its name and the path name
correctly.
I have followed the same steps while creating Excel file and have given
the
same names but still having the problem Please help..

Oct 28 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5583
by: Solel Software | last post by:
Hello, I am looking to open an Excel spreadsheet in ADO.NET using OLEDB's Jet engine. I have a conn string as follows: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.xls;Extended...
4
5182
by: Phoebe. | last post by:
Hi, Good Day! Reading 1 excel file into a dataset is fine. How can I read multiple excel with the same data structure into 1 dataset? How can I append those data? Can someone help? Thanks in...
1
2383
by: svijay | last post by:
hi I have got a strange problem. May I know any solution for this. Here is the detailed description about the problem We have got a mainframe system and also production and development...
0
2017
by: genojoe | last post by:
I have a 4 column, 6 row Excel sheet with all cells formatted for text: 1 1 a a 2 2 b b 3 3 c c a 4 d 1 b 5 e 2 c 6 f 3 I have the following schema.ini:
4
6401
by: Abel | last post by:
Hi I try to execute an sample how to read and write excel sheets using OleDb When opens the connection, the objConn.Open gave me this error: "Request for the permission of type...
1
5291
by: tommydnp | last post by:
Is there a possibility to insert values into excel using only an oledb connection? It's no problem for me to select all data, but when I want to insert data or create a table, there's a problem. ...
2
5013
by: tshad | last post by:
I have a program that is reading a csv file into a dataset. I want it to read the 1st line as data. But it ignores it. I have the Connection set up as: OleDbConnection csvConnection = new...
4
3525
ammoos
by: ammoos | last post by:
Hi Friends, I need to read data from an excel sheet. I am keeping this excel sheet in a remote machine. I am using OLEDB connection to read the data from this excel sheet. But when I am trying to...
2
4927
by: vasanth chandrasekaran | last post by:
Hai All, I try to insert the Dataset value in Exiting excel file by using OLEDB provider.But i face error messagge in objCmd.ExecuteNonQuery(); The error is :Syntax error in INSERT...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.