.net StoredProcedure超时 [英] .net StoredProcedure timeout

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

问题描述

我开发了一个.net(框架版本为1.14322)项目.

.net程序是:

I developed a .net(framework ver is 1.14322) project.

.net program is:

string strConn = System.Configuration.ConfigurationSettings.AppSettings.Get("SQL_CONNSTRING");
SqlConnection DbConnection = new SqlConnection(strConn);
SqlCommand command = new SqlCommand( "pro_SaleThrough", DbConnection );
DbConnection.Open();
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@wkcode", SqlDbType.Char, 10);
command.Parameters.Add("@CCheckFlag",SqlDbType.Char,1);
command.Parameters["@wkcode"].Value = ddlwkcode.SelectedValue.ToString().Trim();			
command.Parameters["@CCheckFlag"].Direction = ParameterDirection.Output;
command.ExecuteNonQuery();



它称为sql server 2005存储过程.
有时会出现错误,错误消息会超时.
存储过程只是插入,更新,删除.
例如:
从Sales插入SalesHistory(MainGUID,SaleNum,SalePrice).

SalesHistory表具有600,000条记录.
销售表每天有2,000条记录
系统每天从Sales表插入到SalesHistory表.

那么谁能帮我解决这个问题呢?



It''s call sql server 2005 stored procedure.
Sometimes it''ll be error and error message is timeout.
The stored procedure just does insert, update, delete.
For Example:
insert into SalesHistory (MainGUID,SaleNum,SalePrice) FROM Sales.

The SalesHistory table has 600,000 records.
Sales table has 2,000 records every day
system is inserted from Sales table to SalesHistory table everyday.

So who can help me solve this issue?
Thanks!

推荐答案

SQLCommand对象应具有commandtimeout属性,您可以将其设置为所需的任何值,或者如果您不希望命令超时,则进行设置到0.(时间单位是秒).

默认值为30.

The SQLCommand object should have a commandtimeout property, you can set this to any value you want, or if you never want the command to timeout then set it to 0. (Time unit is seconds).

The default value is 30.

SqlCommand command = new SqlCommand( "pro_SaleThrough", DbConnection );
command.CommandTimeout = 0;


感谢您的答复!
但仍然会出错!
我不知道该怎么办!:mad:
thank you for your replying!
but still error!
I have no idea how to do!:mad:


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

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