473,654 Members | 3,098 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(objec t sender, EventArgs e)
{

String connectionStrin g =@"Provider=Mic rosoft.Jet.OLED B.4.0;Data
Source=C:\Inetp ub\wwwroot\Exce lData.xls;Exten ded Properties=Exce l 8.0;";
OleDbConnection con = new OleDbConnection (connectionStri ng);
con.Open();
OleDbCommand cmd = new OleDbCommand("S ELECT * FROM myrange1", con);

OleDbDataAdapte r da = new OleDbDataAdapte r();
da.SelectComman d = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "XLData");
//da.Fill(ds, "ExcelData" );
GridView1.DataS ource = ds.Tables[0].DefaultView;
//GridView1.DataS ource = ds;
GridView1.DataB ind();
con.Close();

}
I have included name space:using System.Data.Ole Db;
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 10405

Try
[range1$]

When googling, search for
[Sheet1$]

which is the most common example type syntax

"Shees Abidi" <Shees Ab***@discussio ns.microsoft.co mwrote in message
news:BE******** *************** ***********@mic rosoft.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(objec t sender, EventArgs e)
{

String connectionStrin g =@"Provider=Mic rosoft.Jet.OLED B.4.0;Data
Source=C:\Inetp ub\wwwroot\Exce lData.xls;Exten ded Properties=Exce l 8.0;";
OleDbConnection con = new OleDbConnection (connectionStri ng);
con.Open();
OleDbCommand cmd = new OleDbCommand("S ELECT * FROM myrange1", con);

OleDbDataAdapte r da = new OleDbDataAdapte r();
da.SelectComman d = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "XLData");
//da.Fill(ds, "ExcelData" );
GridView1.DataS ource = ds.Tables[0].DefaultView;
//GridView1.DataS ource = ds;
GridView1.DataB ind();
con.Close();

}
I have included name space:using System.Data.Ole Db;
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
5595
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 Properties=Excel 8.0; I am attempting to put together the SQL to query this spreadsheet. The examples I have found all look like: Select * From
4
5198
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 advanced. rgds,
1
2399
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 server.
0
2031
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
6411
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 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." And appears the following message: System.Exception {System.Security.SecurityException} Any idea to solve this error? I work with VS...
1
5298
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. When I want to insert I always get: "Operation must use an updateable query". When I want to create a table I get a message that it's a read-only database. sql.CommandText = "insert into (, ) values('1', '2')"
2
5018
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 OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvPath + ";Extended Properties=\"Text;HDR=Yes;FMT=Delimited\"");
4
3528
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 read the data, then I am getting the error message “It is already opened exclusively by another user, or you need permission to view its data.” I am sure the file is not opened by another user. Then may I know what I have to do for getting permission...
2
4937
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 INTO statement.
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4149
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
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 we have to send another system
1
1916
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.