How to properly read data from a CSV file 
Author Message
 How to properly read data from a CSV file

I could connect properly but failed to get the data out either as string or
as float value, the data.csv is in the 'C:\Data' folder:

   float fField1;//string strField1;
   string s="Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Data\\;Extended Properties=Text;";//tried adding HDR FMT
   OleDbConnection objConn=new OleDbConnection(s);
   objConn.Open();
   OleDbCommand objComm=new OleDbCommand("select * from data.csv",objConn);
   OleDbDataReader objReader;
   objReader=objComm.ExecuteReader();

   while(objReader.Read())
   {
    fField1=objReader.GetFloat(1);//strField1=objReader.GetString(1); //
both failed here with 'System.InvalidCastException'
   }

Anyone could suggest some way to debug or ways to fix this? thanks!



Mon, 04 Apr 2005 07:28:21 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. csv files - read

2. csv file -read - newbie question

3. csv file -read - newbie question

4. Can ADOCE read data from a CSV (comma-delimited file) file?

5. Reading file..Saving data in new file...

6. Movie/Sound files, reading data embedded with another file

7. Handling ambiguous CSV data in clipboard

8. Reading text file data into an array

9. How to read text file and access data?

10. How can read the colum data to file resx

11. Reading in data from a file.

12. reading in a file of data

 

 
Powered by phpBB® Forum Software