none
why do i need to use OleDb to read .CSV file ?.....Can .CSV file contain datatype other then string ? RRS feed

  • Question

  • hi...

    I'm just writing some app ...which reads .CSV file and show it on the page ...

    my question is why do i need to use OleDb for reading .CSV file ?

    other is ....Can .csv file contain datatype like ...int,datetime,bit ?

    because .csv file is text based file ...isn't it ?   

    Thursday, August 9, 2012 5:15 PM

Answers

  • You don't need to use OLEDB to read a .CSV file unless you want to use the Text ISAM driver and optional schema.ini file to define the structure. Yes, you can define the expected data type of a column, using a schema.ini file, prior to reading the data, but since the contents of a .CSV file consists only of text there is no actual associated data type.

    Options to ADO.NET/OLEDB are the StreamReader Class and the TextFieldParser Class.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, August 9, 2012 6:10 PM

All replies

  • You don't need to use OLEDB to read a .CSV file unless you want to use the Text ISAM driver and optional schema.ini file to define the structure. Yes, you can define the expected data type of a column, using a schema.ini file, prior to reading the data, but since the contents of a .CSV file consists only of text there is no actual associated data type.

    Options to ADO.NET/OLEDB are the StreamReader Class and the TextFieldParser Class.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, August 9, 2012 6:10 PM
  • Agree with Paul.

    OLEDB is just an option to read .csv file on RDBMS way. Why people prefer is to use oledb is you can do all kind of DML operations letting OLEDB to do all IO operation.

    .CSV file do not contains data type information (schema) but it can contain any type of data which you may need to validate while reading the data like you do XSD validation for XML for that you can use .in file Paul was talking about.


    Lingaraj Mishra

    Friday, August 10, 2012 8:53 AM