Click here to Skip to main content
15,748,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my application i am reading data from excel and storing in DataTable object
code is as below
string excelFilePath = "D:\\sunny1.xls";
            string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath + ";Extended Properties=Excel 12.0;";
            OleDbConnection excelOledbConObj = new OleDbConnection();
            excelOledbConObj.ConnectionString = connectionString;
            DataTable excelDataTable = new DataTable();
OleDbCommand oledbCmdObj = new OleDbCommand();
            oledbCmdObj.Connection = excelOledbConObj;
                OleDbDataAdapter oldataAdapterObj = new OleDbDataAdapter(oledbCmdObj);
                oledbCmdObj.CommandText = "Select * from [" +sb1.ToString()+"]";

            catch (OleDbException ex)

and my excel data is as follows:-

EmpCode	Title<br />
999312	mr<br />
As9991  miss<br />
when i execute my application  my datatable have data as follows<br />
999312	mr<br />
NULL  miss<br />
why i am getting null value over here

can anyone help me out here. I believe its happen due the different type of data in my EmpCode column
Updated 6-May-11 2:02am

1 solution

Share this answer
spydeehunk 6-May-11 8:28am    
thanks it helped me out much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900