473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using OLEDB to read data from Excel

1 New Member
Hie,

I've been trying to read an excel file using OLEDB. So far so good, I must say. However, problem arises when there are slashes or spaces in my headers. How should I construct my queries so that I can read the data under these headers?

Example
ID Name Location Name Price/Unit
22 Cat Food Cat Store 2.00
25 Dog Food Dog Store 2.50

Getting the IDs and the Names is easy.
SELECT ID, Name FROM [worksheet1$]

But how do I get the Location Names and the Price/Unit?

Thanks in advance
Apr 24 '07 #1
1 2247
jhardman
3,406 Recognized Expert Specialist
Hie,

I've been trying to read an excel file using OLEDB. So far so good, I must say. However, problem arises when there are slashes or spaces in my headers. How should I construct my queries so that I can read the data under these headers?

Example
ID Name Location Name Price/Unit
22 Cat Food Cat Store 2.00
25 Dog Food Dog Store 2.50

Getting the IDs and the Names is easy.
SELECT ID, Name FROM [worksheet1$]

But how do I get the Location Names and the Price/Unit?

Thanks in advance
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [worksheet1$]
you should be able to refer to all fields with the field name within square brackets, although generally you don't need to. When the field name has certain special characters (I always noticed that a hyphen caused this problem) you need to enclose the name in square brackets:
Expand|Select|Wrap|Line Numbers
  1. response.write rs("[Price/Unit]")
  2.  
or when you make the query you can have the recordset use a different name:
Expand|Select|Wrap|Line Numbers
  1. query = "SELECT [Price/Unit] AS pU ..."
  2. '...
  3.  
  4. response.write rs("pU")
Let me know if this helps

Jared
Apr 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
6620
by: see_mun_lee | last post by:
I use asp to develop a web page to read an excel file containing Chinese Character then display it in the web page. Unfortunately, I cant display it!!! it will display (?????????). <META...
4
11302
by: RK | last post by:
Hi, In my application, I need to copy data from an Excel file into a SQL table. The article related to this can be found at http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572 ...
2
10659
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
1
8891
by: Roger Twomey | last post by:
I have a form that allows a user to upload a microsoft Excel Spreadsheet. (I am testing with one created in Excel 2000) The spreadsheet is uploaded correctly. It is then supposed to be read...
1
1476
by: EMW | last post by:
I use the following function to read an Excel worksheet into a dataset: Public Function GetDataFromExcel(ByVal FileName As String, ByVal ds As DataSet) As Boolean Try Dim strConn As String =...
1
3241
by: funcSter | last post by:
I want to retrieve data from an Excel file like how I would with a database. I understand that I would have to use OLE DB. Somehow I think I cannot get the connection string right, as the bit of...
3
3272
by: RJN | last post by:
Hi I've a template excel file which has all the calculations defined. There are certain input values to be entered which gives a lot of output to the user. I don't want to expose the excel sheet...
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. ...
1
10386
by: =?Utf-8?B?U2hlZXMgQWJpZGk=?= | last post by:
I read an article on the link: http://support.microsoft.com/default.aspx?scid=kb;en-us;306572 related to reading data from Excel using OLEDB The topic's heading is: How to query and display excel...
0
7372
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
7029
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
7481
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
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
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
3190
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
1537
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
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.