线程问题 [英] Threads issue

查看:60
本文介绍了线程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我用以下语句创建100个表并将值分别插入其中.

Hello,
I''v a following statement with which I''m creating 100 tables and inserting values into it respectively.

cmd1.ExecuteNonQuery();



但是它抛出了诸如超时异常"之类的错误,并且上面的代码并没有完全执行...

我认为.net编译器会在需要更多时间的地方快速执行该语句..

按照我使用线程概念但不清楚的...
您能帮我解决问题吗?



But its throwing a error like "time out exception" and the above is not executing completely...

I think the .net compiler is executing the statement fastly where as it requires bit more time..

As per i''v to use Threads concept but not clear...
Can u help me to solve issue.

推荐答案

超时异常最有可能正在等待SQL Server(或您正在使用的任何数据库)的响应.我强烈建议减少在单个命令中插入的表和值的数量:这可能会花费一些时间,并且可能超出数据库系统响应的超时限制.您可以使用数据库管理器来增加限制(有关如何操作的信息,请使用Google增加超时sql服务器"),但是最好将单个整体命令转换为许多可能已处理的命令,以便您可以回滚.失败.
The time out exception is most likely to be waiting for a response from the SQL server (or whatever database you are using). I would strongly suggest reducing the number of tables and values you insert in a single command: this could take some considerable time and is probably outside the time out limits for your database system to respond. You could increase the limits with your database manager (google "increase timeout sql server" for information on how), but it would be better to look at converting your single monolithic command into a number of commands, possibly transacted so you can roll back in case of failure.


您可以设置cmd1.CommandTimeout.您必须以秒为单位指定时间.

默认情况下为30秒.您的过程可能需要更长的时间.

我认为,创建100张桌子不会花费太多时间.但是我不知道您要向其中添加多少数据!我认为如果您没有填充太多数据,请尝试将300设置为超时.您可以根据需要增加超时时间.
You can set cmd1.CommandTimeout. You have to specify time in seconds.

By default it is 30 seconds. Your procedure may be taking longer than that.

I think, creating 100 tables won''t take much time. But I don''t know how much data you are adding to them! I think if you are not populating much data, try 300 as timeout. You can increase timeout if required.


这篇关于线程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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