This problem occurs when inserting data in bulk.
Workaround: The length of the data should be greater than the defined length of the column corresponding to the data.
So one check is that the length of the column is beyond.
The network provides this method to find out exactly which column is longer than the length.
Public voidgetfiledsizetest () {stringFilefullname =@"D:\GameLogs\2015-01-30_000000\Login.log"; //maximum length for each columndictionary<int,int> dicfieldlength =Newdictionary<int,int>(); //the line number of the maximum length of each columndictionary<int,int> dicmaxfieldlenthrownum =Newdictionary<int,int>(); for(inti =0; I < One; i++) {Dicfieldlength.add (I,0); Dicmaxfieldlenthrownum.add (i,0); } if(NewFileInfo (Filefullname). Length >0) { using(StreamReader sr =NewStreamReader (Filefullname, Encoding.UTF8)) { intRowNum =0; while(Sr.) Peek () >-1) { stringStrrow =Sr. ReadLine (); RowNum++; Object[] Objrow = Strrow.split (','); for(inti =0; i < objrow.length; i++) { varlen=Objrow[i]. ToString (). Length; if(Dicfieldlength[i] <Len) {Dicfieldlength[i]=Len; Dicmaxfieldlenthrownum[i]=RowNum; } } } } }}
A column length that is not valid for Colid X is received from the BCP client.