I am creating a utility to import data from Excel into an Oracle database,
I have a fixed template for an excel file,
Now, when I try to import data using the Jet provider and ADO.Net - Ole, I found the following problem: some columns were not imported because their mixed data types have mixed data types columns [row and number],
I searched this problem online. I found a reason to guess data types from Excel
Download Code:
connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0};Extended Properties=Excel 8.0;"); string columns = "P_ID, FULL_NAME_AR, job_no, GENDER, BIRTH_DATE, RELIGION, MARITAL_STATUS, NAT_ID, JOB_Name, FIRST_HIRE_DATE, HIRE_DATE, CONTRACT_TYPE, GRADE_CODE, QUALIFICATION"; string sheetName = "[Emps$]"; OleDbCommand command = new OleDbCommand(string.Format("select {0} from {1} where p_id is not null", columns, sheetName), connection); connection.Open(); dr = command.ExecuteReader(); DataTable table = new DataTable(); table.Load(dr);
What should I do to tell Excel STOP GUESSING and provide me data as text?
If not, can you help me with any workarounds?
Thanks in advance
Homam
source share