import CSV file in to DataSet

  • Thread starter Thread starter Mohan
  • Start date Start date
M

Mohan

Hi Friends,

I have an issue in importing csv file in to a Dot net data
set using Microsoft.Jet.OLEDB.4.0 provider.
I am able to import the csv file in to data set when the
file has less than 256 columns. If it has more than 256
columns, its not importing the columns beyond the 256
columns.

Could you please help me on this.

code snippet:

System.Data.OleDb.OleDbConnection oCon = 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 ["+ fileName +"]",

oCon);


oCmd.Fill(myDS);

thanks
Mohan
 
Mohan:

I just ran this code as a Test and it easily let me add 3001 columns. I know
the row capacity is 16,777,216 but I haven't seen anything about DataColums
(3,000 columns is more than plenty). Can you post your parsing code b/c it
may well be something in the loop that you are using that is causing the
problem.

HTH, Bill

Dim Dt As New DataTable

For i As Integer = 0 To 3000

Dim dc As New DataColumn

Dt.Columns.Add(dc)

Next

MessageBox.Show(Dt.Columns.Count.ToString)
 
Hi Ryan,
Thanks for your immediate response.
There is no problem in adding more columns in DataSet.
The proble is creating a DataSet from the CSV file.
If CSV file has more than 256 columns, Oledb provider
Microsoft.Jet.OLEDB.4.0 not able to create a dataset with
all columns.
It seems that this provider supports only 256 columns.
I hope its clear.

thanks
Mohan
-----Original Message-----
Mohan:

I just ran this code as a Test and it easily let me add 3001 columns. I know
the row capacity is 16,777,216 but I haven't seen anything about DataColums
(3,000 columns is more than plenty). Can you post your parsing code b/c it
may well be something in the loop that you are using that is causing the
problem.

HTH, Bill

Dim Dt As New DataTable

For i As Integer = 0 To 3000

Dim dc As New DataColumn

Dt.Columns.Add(dc)

Next

MessageBox.Show(Dt.Columns.Count.ToString)

Mohan said:
Hi Friends,

I have an issue in importing csv file in to a Dot net data
set using Microsoft.Jet.OLEDB.4.0 provider.
I am able to import the csv file in to data set when the
file has less than 256 columns. If it has more than 256
columns, its not importing the columns beyond the 256
columns.

Could you please help me on this.

code snippet:

System.Data.OleDb.OleDbConnection oCon = 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 ["+ fileName +"]",

oCon);


oCmd.Fill(myDS);

thanks
Mohan


.
 
Accessing Csv Files In A Macro

Hi,

Pls Tell Me How To Access The Data From Csv Files, In A Macro. I Need To Read From 7 Files..

Jagan
 
Back
Top