Solved

opening a csv file using oledb extended property

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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