SqlClient.SqlException: The wait operation timed out

我的未来我决定 提交于 2019-12-08 04:19:56

问题


I'm currently trying to create a large amount of test data with numerous insert statements using code similar to below...

using (var connection = new SqlConnection(_connectionString))
{
    using (var command = new SqlCommand(query.ToString(), connection))
    {
        try
        {
            connection.Open();

            command.ExecuteNonQuery();

            return true;
        }
        catch (Exception e)
        {
            ......
        }
    }
}

My problem is that I keep getting an error

The wait operation timed out

and yet when I run the SQL statement that failed from within SQL Server Management Studio, it executes in less than 100ms. The error always seems to occur whilst inserting into the largest table which currently has 47,738,476 rows and is 1,970,696Kb in size.

I'm using:

Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64) 
Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

Any, help would be most appreciated.


回答1:


Disclaimer: It may not be an answer but it solves the problem :)

Use Redgate Sql Data Generator

http://www.red-gate.com/products/sql-development/sql-data-generator/

It is not free but it is fully functional trial for some days and it will do the work for you what i want to achieve.

It had lot of option and generate real looking data.



来源:https://stackoverflow.com/questions/25094681/sqlclient-sqlexception-the-wait-operation-timed-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!