Source: http://www.lmwlove.com/ac/ID473
I made a small tool and used sqlbulkcopy to import data to the database in batches. I used it well before. When I was using it today, I reported a transmission-level error when receiving results from the server. (Provider: Provided By TCPProgram, Error: 0-the specified network name is no longer available.) I thought it was a problem with the server. I checked it and confirmed that there was no problem with the server. I thought it was a column ing error. Check and debug carefully. There is still no problem. Crazy ......
Honestly from the data source check, suddenly found that the length of a column in a row of data in the data source exceeds the length of the database field, is this the problem? I changed the field length to a higher value. The test passed and finally found the cause ......
Conclusion: when using sqlbulkcopy to import data, if the data length of the data source exceeds the length of the database field, the sqlserver service is disabled, leading to a transmission-level error when receiving results from the server. (Provider: TCP provider, error: 0-the specified network name is no longer available) error.
However, I have never figured out that an error that exceeds the field length should be returned if it exceeds the field length. Why is it so serious to close the sqlserver service?