Solved

csv and oledb ?

Posted on 2004-10-07
3
706 Views
Last Modified: 2010-07-27


hi

I want to load from a csv file, all the data to a dataset using oledb connection.

when i use:

string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended Properties=text;";

OleDbDataAdapter oleCmd = new OleDbDataAdapter("SELECT * FROM NEWTESTApr.csv", strConn);

my code runs fine, but when i add either HDR, or FMT to the string connection like:

string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended Properties=text;HDR=No;FMT=Delimited;";
         
it gives me an exception : could not find installable ISAM.

can anyone throw more light on this .. why this is happening ?


thanks
messageman
0
Comment
Question by:messageforums
  • 2
3 Comments
 
LVL 8

Expert Comment

by:gregasm
ID: 12255931
Hey messageman,

Have a look here. This might shed some light on the issue:

http://www.dotnet247.com/247reference/msgs/12/61447.aspx
0
 

Author Comment

by:messageforums
ID: 12263167
hi

thanks for the link and the topic on ISAM. that was very helpful.

I did not modify any registries yet, but my question is that
if it runs for the first command that i give., then the addition of HDR or FMT should not matter as long as the connection is valid.

but why just by the addition of those will the system give errors ????


please let me know
messageman
0
 
LVL 8

Accepted Solution

by:
gregasm earned 50 total points
ID: 12263500
Can you try this code?

System.Data.OleDb.OleDbConnection oConn = new
System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + PathtoTextFile + ";" +
"Extended Properties=\"text;HDR=YES;FMT=Delimited\"");
System.Data.OleDb.OleDbDataAdapter oCmd = new
System.Data.OleDb.OleDbDataAdapter(
"select * from csv.txt",
oConn);

DataSet myDS = new DataSet();
oCmd.Fill(myDS);
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Search by two fields at the same time using c# radio button 5 39
Connecting database in Xamarin? 6 50
Connection String 16 43
Error in script 11 45
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

26 Experts available now in Live!

Get 1:1 Help Now