Import CSV

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • benoit

    #1

    Import CSV

    Hi,

    when I load a CSV file into a DataSet, and try to display it in a gridView,
    it clearly only displays the first column.
    what am i forgetting?
    this is my code

    OleDbConnection ExcelConnection = new
    OleDbConnection (@"Provider=Mic rosoft.Jet.OLED B.4.0;Data Source=" + pathName +
    ";Extended Properties='tex t;HDR=No;FMT=De limited'");
    //

    OleDbCommand ExcelCommand = new OleDbCommand(@" SELECT * FROM " +
    fileName, ExcelConnection );

    OleDbDataAdapte r ExcelAdapter = new OleDbDataAdapte r(ExcelCommand) ;
    ExcelConnection .Open();

    DataSet ExcelDataSet = new DataSet();
    ExcelAdapter.Fi ll(ExcelDataSet );

    ExcelConnection .Close();
    return ExcelDataSet;
  • Ken Cox - Microsoft MVP

    #2
    Re: Import CSV

    Hi Benoit,

    Are you selecting the correct range from the worksheet?

    How To Query and Display Excel Data by Using ASP.NET, ADO.NET, and Visual
    Basic .NET

    http://support.microsoft.com/default...;en-us;Q311731

    Ken
    Microsoft MVP [ASP.NET]


    "benoit" <benoit@discuss ions.microsoft. com> wrote in message
    news:FEADFB9D-6359-4B32-A9E7-4C13341F6253@mi crosoft.com...[color=blue]
    > Hi,
    >
    > when I load a CSV file into a DataSet, and try to display it in a
    > gridView,
    > it clearly only displays the first column.
    > what am i forgetting?
    > this is my code
    >
    > OleDbConnection ExcelConnection = new
    > OleDbConnection (@"Provider=Mic rosoft.Jet.OLED B.4.0;Data Source=" +
    > pathName +
    > ";Extended Properties='tex t;HDR=No;FMT=De limited'");
    > //
    >
    > OleDbCommand ExcelCommand = new OleDbCommand(@" SELECT * FROM " +
    > fileName, ExcelConnection );
    >
    > OleDbDataAdapte r ExcelAdapter = new OleDbDataAdapte r(ExcelCommand) ;
    > ExcelConnection .Open();
    >
    > DataSet ExcelDataSet = new DataSet();
    > ExcelAdapter.Fi ll(ExcelDataSet );
    >
    > ExcelConnection .Close();
    > return ExcelDataSet;[/color]


    Comment

    Working...