Solved

opening a csv file using oledb extended property

Posted on 2006-10-25
3
2,421 Views
Last Modified: 2012-08-13
I have a .CSV file (comma delimited) that I want to open using OLEDB, but I
get the error "External table is not in the expected format."
If I save the .CSV file to an .XLS file, I can open the connection with no
problem.
What is the correct way to open a .CSV file ?
If I can not open the CSV file, how can I programmatically save the CSV file
to an XLS file ?
Thanks a lot.

dim myCon OleDb.OleDbConnection
myCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\file.csv; Extended Properties=""Excel 8.0; HDR=NO; IMEX=1""")
--> error "External table is not in the expected format."

I also made Extended Properties = text
Then also it gives me error --> path not found for the file.

Thanks
0
Comment
Question by:r_pat72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17803292
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 17803318
dim myCon OleDb.OleDbConnection
myCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\; Extended Properties=""text; HDR=NO; IMEX=1""")

Dim _file as string
_file="file.csv"
Dim cmd As New OleDb.OleDbCommand("select * from [" & _file & "]", myCon)
        Dim da As New OleDb.OleDbDataAdapter(cmd)
0
 

Author Comment

by:r_pat72
ID: 17809349
Thanks..

it worked for data source c:\.

But when I am giving the path of data source of c:\testsite\testfiles ,it gives me error invalid path.

As I have to keep the file.csv file in c:\testsite\testfiles  folder.

I have IIS default web site, mapped to c:\testsite.

Could any one give me the solution for this.

Thanks




0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question