Accepted answer

you need to specify the column as integer while defining the datatable. like this:-

datatable.columns.add("customerid", typeof(int));

the other reason i suspect is probably the way you are binding your datatable (i mean the order of columns) doesn't match with that of database table. reason being i think default mapping is not name to name rather its index to index in sqlbulkcopy. so kindly re-check your database table order, it should look like:-

customerid (int)
firstname (varchar\nvarchar)
lastname (varchar\nvarchar)
showsnumber (int)
visitnumber (int)
cancellation (int)


as far as i am aware, you need to set the type of the column on the datatable, otherwise it will presume string (because nearly everything can be converted as such).

before you set the values, try:

datatable.columns[2].type = typeof (int);

or, alternatively, you can specify it when defining the columns:

datatable.columns.add("showsnumber", typeof(int));

Related Query

More Query from same tag