import CSV

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Group,

I want to import the csv format data into my progrm frm C# using oledb/odbc.
Is it possible, how?

Please Help,
Rahul.
 
Yes you can. If you want to import it to a database inside your program,
here is a simple but working code.
At the same token, if you want to display it on datagrid in your form create
a dataset and populate your datagrid.
Yonas
try

{

string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\temp\yourdb.mdb";

OleDbConnection conn = new OleDbConnection(strConn);

conn.Open();

OleDbCommand cmd = new OleDbCommand();


cmd = new OleDbCommand("INSERT INTO Fattributes Select * from
[Text;DATABASE=c:\\temp;].[mydata.csv]",conn );

cmd.ExecuteNonQuery();

conn.Close();

}

catch

{

MessageBox.Show("Error Occured");

}
 
Hi,

You can use MS Jet I believe, but take a look at the CSV provider from
www.opennetcf.org I'm using it as it does not require Jet to be installed
and it also work in mobile devices.


cheers,
 
Back
Top