0

ConnectionString:

ConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dynParams.FilterLink +
                        ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

 var Sheets = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    string sht = dynParams.FilterName;//(from DataRow dr in Sheets.Rows select dr[2].ToString().Replace("'", "")).FirstOrDefault();

                    var query = "SELECT * FROM [" + sht + "]";
                    var cmd = new OleDbCommand(query, conn);
                    // create a data adapter and get the data into dataadapter
                    var da = new OleDbDataAdapter(cmd);
                    var ds = new DataSet();
                    //fill the Excel data to data set
                    da.Fill(ds);

Excel data:

01.09.2020
01.09.2006
07.02.2011
14.02.2004
27.12.2017
13.10.2017
25.09.2018
01.07.2020
06.02.2012
05.12.2017
02.08.2018
19.02.2019
08.10.2014
13.06.2016
02.05.2019
05.09.2017
07.10.2005
20.05.2013
28.01.2008

Returned data:

01/09/2020
01/09/2006
07.02.2011
14.02.2004
27.12.2017
13.10.2017
25.09.2018
01.07.2020
06/02/2012
05.12.2017
02.08.2018
19.02.2019
08.10.2014
13.06.2016
02.05.2019
05/09/2017
07/10/2005
20.05.2013
28.01.2008

It is possible that the date format is not the same and the format comes in mm / dd / yyyy. When I did some research, it was written that the IMEX = 1 field should be changed, but although I tried this, I could not get any results.

  • Apart from the bottom list sometimes having / as separators instead of .s, I can't see any difference with the actual day, month and year numbers between the first list and second list. – Paul Apr 30 '21 at 12:35
  • Thats true, there is no wrong data in the list. I found that the problem was only on a single server. Since I do not have access to that found server at the moment, I cannot put the erroneous data. – Berk Colak Apr 30 '21 at 14:45
  • @Berk Colak, you can change the date format to the same format in the initial excel. Please refer to [How to make correct date format when writing data to Excel](https://stackoverflow.com/a/3310837/11507778). – Jack J Jun May 03 '21 at 02:21

0 Answers0