Data from excel to sql tabel is importing in NULL values...why??
01:51 01 Jun 2013

I am importing data from excel to database. Following is schema of excel columns: below is the schema of db....and exactly matches with excel sheet data....................

ID  integer                 
organizationId  integer             
categoryId  integer         
attribute   text          
Y1960       integer or null     
Y1961       integer or null      
Y1962       integer or null       
Y1963       integer or null      
Y1964       integer or null     
Y1965       integer or null       
Y1966       integer or null      
Y1967       integer or null       
Y1968       integer or null      
Y1969       integer or null

And same is in database columns. I am using following code to retrieve data of first 10 columns from excel file.

OleDbConnection excelConnection =
                        new OleDbConnection(excelConnectionString);

        //Create OleDbCommand to fetch data from Excel
        OleDbCommand cmd = new OleDbCommand
        ("Select [ID],[organizationID],[categoryID],[parentID],[granularityLevel],[attribute],[Y1960],[Y1961],[Y1962],[Y1963],[Y1964],[Y1965] from [Details$]", excelConnection);

        excelConnection.Open();
        OleDbDataReader dReader;
        dReader = cmd.ExecuteReader();

        SqlBulkCopy sqlBulk = new SqlBulkCopy(connectionString);
        sqlBulk.DestinationTableName = "Data";
        sqlBulk.WriteToServer(dReader);

Problem is that data of Y1960 column is not copied into database table from excel file. Other columns are copied, but Y1960 is not copied. Only null value is available there.

c# sql excel