简体   繁体   English

SqlClient.SqlException:等待操作超时

[英]SqlClient.SqlException: The wait operation timed out

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. 但是,当我在SQL Server Management Studio中运行失败的SQL语句时,它的执行时间不到100毫秒。 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. 插入当前最大的表(当前有47,738,476行,大小为1,970,696Kb)时,似乎总是会发生该错误。

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. 非常感激任何的帮助。

Disclaimer: It may not be an answer but it solves the problem :) 免责声明:可能不是答案,但可以解决问题:)

Use Redgate Sql Data Generator 使用Redgate Sql数据生成器

http://www.red-gate.com/products/sql-development/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. 它有很多选择,并可以生成真实的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM