Solved

opening a csv file using oledb extended property

Posted on 2006-10-25
3
2,409 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
  • 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now