简体   繁体   中英

fetch datetime from a Excel sheet through OleDbDataAdapter

i am facing a problem when i fetch datetime column from Excel containing CSV format values then its show null because the value on datetime column is like 50:48:12 (HH:MM:SS), but when the value is under datetime range like 23:12:32 then its working perfect...

i want to fetch the Excel column with any datetime value eg if the value is 50:48:12 then i got the same value on Query result

my snap code is below my OleDbDataAdapter connection is string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=\\"" + dir + "\\\\\\";" + "Extended Properties=\\"text;HDR=No;FMT=Delimited\\""; string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=\\"" + dir + "\\\\\\";" + "Extended Properties=\\"text;HDR=No;FMT=Delimited\\"";

My query is string query = "SELECT * FROM " + file;

OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);

        try
        {
            //fill the DataTable
            dAdapter.Fill(dTable);
        }

Values In Excel Sheet is 104:24:54 22:12:34 720:01:00

and if i open dataTable then

  1. value in dTable.Tables[0].Rows[0] is null
  2. value in dTable.Tables[0].Rows[1] is 10:12:34 PM
  3. value in dTable.Tables[0].Rows[2] is null

please give me any solution

Your date values are not captured in a valid format 104:24:54 & 720:01:00. 22:12:34 is the only valid one. Why are the other value higher than 24.00.00?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM