Ok so here's the thing, I used to read in data from an excel file and bulk copy this data into a SQL table and everything worked fine. But now, my source file changed, so now i get data from a other excel file. Both file look exactly the same, I can still read in the data through the program, but now, when I bulk copy the data to a SQL table, instead of inserting the values, it inserts "NULL" into the column...I just don't know what is going on. My program still works fine with the other source file.

My BulkCopy Code:

using (SqlBulkCopy bulkCopy = new SqlBulkCopy(thisConnection))
      {
          bulkCopy.DestinationTableName =
            "tbl_" + Release.Text + "_NEW_VERSION_FILE";

         try
           {
               bulkCopy.WriteToServer(AddTermTable);
           }

         catch (Exception ex)
           {
               Console.WriteLine(ex.Message);
               thisConnection.Close();
               Console.ReadLine();
           }

         finally
           {
                thisConnection.Close();
           }
      } 

Attached (GUI) , you will see a picture of my GUI that has the data from the New source file attached to a datagrid.
The second attachment is a picture of how it looks in SQL.

Can anyone help me understand this?

If you're still interested, in the left screen grab you've highlight all but there WHERE clause which means that only the highlighted code will be executed and nulls will be returned.

yeah i made a stupid mistake, bulk copy doesn't care which column it copies the data to, as long as the number of columns for the source and destination is the same, so the data did copy to the first column of the table, which is not shown with my sql query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.