none
retrieving value from excel RRS feed

  • Question

  • Hi while retrieving data from excel i am not able to get the values of two field

    i have excel with 5 field Reference, Name, Remarks, Time, Date

    OleDbDataAdapter

    da1 = new OleDbDataAdapter("select [Work Order No], [Status], [Remarks], [Time], [Date] from [Sheet1$] where [Status]<> null", conn1);

     

    DataTable dt1 = new DataTable();

    da1.Fill(dt1);

     

    dataGridView1.DataSource = dt1;

     

    If there is value for time and date field in first cell then it is working fine but if there is no value in first cell for these field then it is not showing values of date and time field.

    Time value has integer variable and date has date...

    Monday, May 23, 2011 12:17 PM

Answers

  • The Excel ISAM generally will guess, based upon the contents of the first eight rows by default, as to the data type of the column. This can result in data truncation or missing data altogether. 

    You can try adding the IMEX=1 argument to the connection string to import as text or change the TypeGuessRows value in the registry:

    http://support.microsoft.com/kb/281517

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Monday, May 23, 2011 5:38 PM

All replies

  • The Excel ISAM generally will guess, based upon the contents of the first eight rows by default, as to the data type of the column. This can result in data truncation or missing data altogether. 

    You can try adding the IMEX=1 argument to the connection string to import as text or change the TypeGuessRows value in the registry:

    http://support.microsoft.com/kb/281517

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Monday, May 23, 2011 5:38 PM
  • Thanks paul it's working great!!!!!!!!!!
    Tuesday, May 24, 2011 4:25 AM