SqlBulkCopy Error: Cannot insert the value NULL into column C# .Net

Last Reply on Dec 30, 2014 07:48 AM By Mudassar

Posted on Dec 30, 2014 06:30 AM

Good morning, hopefully they can support me I do not want to use bulkcopy or insert Int because when a field is empty in the file shows me an error. Not that I would recommend alternate method.

Thank You,

         private DataTable CrearTabla_personal(String fila)

             int cantidadColumnas;
             DataTable tabla = new DataTable("Datos");
             String[] valores = fila.Split(new char[] { '|' });
             cantidadColumnas = valores.Length;
             int idx = 0;
             foreach (String val in valores)
                 String nombreColumna = String.Format("{0}", idx++);
                 tabla.Columns.Add(nombreColumna, Type.GetType("System.String"));
             return tabla;
Posted on Dec 30, 2014 07:48 AM