我使用以下代码:
'item being 14
mySQLdel = "DELETE FROM table WHERE ID= " & item
response.write "<p>SQL Command: " & mySQLdel & "</p>"
myConn.Execute(mySQLdel)
是否存在id为14的记录,我得到:
DELETE FROM表WHERE ID = 14
Microsoft OLE DB Provider for SQL Server错误“80040e31”
查询超时已过期
/index.asp,第58行
第58行:
myConn.Execute(mySQLdel)
等效命令可以很好地处理另一个表,所以我认为它与权限有关,虽然不能在我的生活中找出什么。
当我在SQL Management Studio中运行相同的SQL时,查询几乎立即执行。
以下是请求的创建脚本:
USE [user1]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tablename](
[id] [int] IDENTITY(1,1) NOT NULL,
[var1] [nvarchar](max) NULL,
[var2] [int] NULL,
[var3] [int] NULL,
[var4] [nvarchar](50) NULL,
[datecreated] [datetime] NULL
) ON [PRIMARY]
GO
sys.dm_os_waiting_tasks
显示
+----------------------+------------+-----------------+------------------+-----------+--------------------+-----------------------+---------------------+--------------------------+--------------------------------------------------------------------------------------------------+--+
| waiting_task_address | session_id | exec_context_id | wait_duration_ms | wait_type | resource_address | blocking_task_address | blocking_session_id | blocking_exec_context_id | resource_description | |
+----------------------+------------+-----------------+------------------+-----------+--------------------+-----------------------+---------------------+--------------------------+--------------------------------------------------------------------------------------------------+--+
| 0x00000000041F7288 | 63 | 0 | 7139 | LCK_M_U | 0x00000000869F2C40 | NULL | 69 | NULL | ridlock fileid=1 pageid=214 dbid=61 id=lock847e0b00 mode=U associatedObjectId=72057594039435264 | |
+----------------------+------------+-----------------+------------------+-----------+--------------------+-----------------------+---------------------+--------------------------+--------------------------------------------------------------------------------------------------+--+
有什么想法吗?
谢谢。
答案 0 :(得分:2)
有许多事情可能导致sql server花费比预期更长的时间来执行某些操作。当你进行删除时,它可能会级联到其他表中,例如。您需要做的只是在执行命令之前增加命令的超时。
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout = 0; //no timeout
cmd.CommandText = "delete from foo;";
答案 1 :(得分:0)
好吧......我一定要吃不起的馅饼......
我正在做的是从table1调用记录然后执行类似的操作:
if not myRS.eof then
delete from table1
end if
一旦我更改了代码,一切都很好......