SqlClient.SqlException:等待操作超时 [英] SqlClient.SqlException: The wait operation timed out

查看:29
本文介绍了SqlClient.SqlException:等待操作超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用类似于下面的代码创建大量带有大量插入语句的测试数据...

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

等待操作超时

然而,当我在 SQL Server Management Studio 中运行失败的 SQL 语句时,它的执行时间不到 100 毫秒.该错误似乎总是在插入到当前有 47,738,476 行且大小为 1,970,696Kb 的最大表中时发生.

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.

我正在使用:

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 :)

使用 Redgate Sql 数据生成器

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.

这篇关于SqlClient.SqlException:等待操作超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆