I have found the solution. I am using bulk copy so i just increased the bulkcopy timeout value and it works.
bulkCopy.BulkCopyTimeout = 9999;
bulkCopy.WriteToServer(dr);
I just wrote the Time out code before writing to the server.
문제
I have created an win form application. Where I take Excel file and upload the data into Database.But when i am trying to upload data it is showing error "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." I have changed the connection time out property
But still its showing same error. N.B: It works once then again show the problem. My Excel file contain more than 0.5million Data
해결책 2
I have found the solution. I am using bulk copy so i just increased the bulkcopy timeout value and it works.
bulkCopy.BulkCopyTimeout = 9999;
bulkCopy.WriteToServer(dr);
I just wrote the Time out code before writing to the server.
다른 팁
Setting connection timeout is not relevant, make sure you have the CommandTimeout property set in your Command object,
SqlCommand command = new SqlCommand();
command.CommandTimeout = 0; //Wait indefinitely
For more information, http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout%28v=vs.110%29.aspx
Uploading large quantity of data(half million, in your case) one record at a time is not recommended. Use SqlBulkCopy as it will be more efficient, read excel file, copy records to a text file and bulk upload, http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx