3

I am using following function in my code,to read excel input but one of the column from excel is CreateDate at that point it is not accepting MM/dd/yyyy date format.
Please suggest me appropriate changes to do the same. Thanks in advance.

using (OleDbConnection conn = new OleDbConnection(connStr))
 {
    conn.Open();
    DataTable dtsheet =conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,null);
    string ExcelSheetName = dtsheet.Rows[0]["Table_Name"].ToString();
    // "Excel file read"
    string sheet = @"SELECT Format([create date],   FROM [" + ExcelSheetName + "]"; 
    using (OleDbDataAdapter ad = new OleDbDataAdapter(connStr, conn))
       {
            ad.Fill(dt);
       }
            conn.Close();
 }
autistic
  • 1
  • 3
  • 35
  • 80

0 Answers0