我已经存储Topounce
了从动态表中获取最高记录并将其从 PC 中读出的存储过程。当记录太多时,它会超时
SqlDataReader dr2 = select.ExecuteReader()
目前大约有 750 条记录。我已经尝试过CommandTimeOut = 0
了,大约需要 10 分钟才能说出录音。有没有解决的办法?
这是错误:
超时已过。在操作完成之前超时时间已过或服务器没有响应。
代码:
try
{
using (SqlConnection connStr2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString))
{
//Selects top record from vwAnno
SqlCommand select = new SqlCommand("Topounce", connStr2);
select.CommandType = CommandType.StoredProcedure;
select.Parameters.AddWithValue("@ID", (string)Num);
connStr2.Open();
SqlDataReader dr2 = select.ExecuteReader(); // TIMES OUT HERE
//Reads record in vwAnnounce
while (dr2.Read())
{
//do work
}
dr2.Close(); //Close Datareader connection
connStr2.Close();
}
这里的UPDATE 是存储过程。
USE [Queue]
GO
/****** Object: StoredProcedure [dbo].[TopRowViewAnnounce] Script Date: 06/01/2013 11:55:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[TopRowViewAnnounce]
@QueueID int
AS
BEGIN
SELECT TOP 1 id, qdate, ticket_number, QID, received, displaynum, station, transcodevoiced FROM vwAnnounce WHERE QID = @ID ORDER by received ASC
END
我做一个存储过程的原因是因为我认为它会帮助超时。我原来是这样的。
SqlCommand select = new SqlCommand("SELECT TOP 1 id, qdate, ticket_number, QID, received, displaynum, station, transcodevoiced FROM vwAnnounce WHERE QID = @ID ORDER by received ASC", connStr2);
select.CommandType = CommandType.StoredProcedure;
select.Parameters.AddWithValue("@ID", (string)Num);
connStr2.Open();
SqlDataReader dr2 = select.ExecuteReader(); // TIMES OUT HERE
我仍然没有得到解决方案。有人吗?