Importing from excel

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

    Importing from excel

    OleDbConnection excel1 = new OleDbConnection ();

    excel1.Connecti onString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
    Source=C:\\Docu ments and Settings\\Jed\\ My Documents\\pro cd\
    \testsheet.xls; Extended Properties=Exce l 8.0;";
    OleDbDataAdapte r fillds = new OleDbDataAdapte r("SELECT
    Barcode,Part_Co unt,Cycle_Time FROM [Sheet1$]", excel1);

    System.Data.Dat aTable ds = new
    System.Data.Dat aTable();
    fillds.Fill(ds) ;

    This is the code i am using but i am getting this error when i execute
    the fill statement.

    External table is not in the expected format.

    What am i doing wrong here?Please help. thanks in advance
  • DSK Chakravarthy

    #2
    Re: Importing from excel

    The error is meaningful .. there is some issue with the data in the Sheet.
    Check that the data type is unique for every column.

    HTH

    "Cdude" <cameljs18@yaho o.comwrote in message
    news:6009852d-4947-4538-84bb-14bdcff186d9@y2 1g2000hsf.googl egroups.com...
    OleDbConnection excel1 = new OleDbConnection ();
    >
    excel1.Connecti onString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
    Source=C:\\Docu ments and Settings\\Jed\\ My Documents\\pro cd\
    \testsheet.xls; Extended Properties=Exce l 8.0;";
    OleDbDataAdapte r fillds = new OleDbDataAdapte r("SELECT
    Barcode,Part_Co unt,Cycle_Time FROM [Sheet1$]", excel1);
    >
    System.Data.Dat aTable ds = new
    System.Data.Dat aTable();
    fillds.Fill(ds) ;
    >
    This is the code i am using but i am getting this error when i execute
    the fill statement.
    >
    External table is not in the expected format.
    >
    What am i doing wrong here?Please help. thanks in advance

    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: Importing from excel

      On May 12, 7:51 am, Cdude <camelj...@yaho o.comwrote:
       OleDbConnection excel1 = new OleDbConnection ();
      >
      excel1.Connecti onString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
      Source=C:\\Docu ments and Settings\\Jed\\ My Documents\\pro cd\
      \testsheet.xls; Extended Properties=Exce l 8.0;";
                      OleDbDataAdapte r fillds = new OleDbDataAdapte r("SELECT
      Barcode,Part_Co unt,Cycle_Time FROM [Sheet1$]", excel1);
      >
                      System.Data.Dat aTable ds = new
      System.Data.Dat aTable();
                      fillds.Fill(ds) ;
      >
      This is the code i am using but i am getting this error when i execute
      the fill statement.
      >
      External table is not in the expected format.
      >
      What am i doing wrong here?Please help. thanks in advance
      Hi,


      I have posted in the past code to read from excel in the way you want,
      do a search in the archives by "ignacio machin" excel code and you
      should find it

      Comment

      Working...