2016-05-16 50 views
-2

我试图在vb.net应用程序来执行此更新查询:vb.net SQL更新查询无法完成

SQL = "UPDATE billing_calldata SET status = 'c', customer = '" & customer_sequence & "', description = '" & description & "', customer_cost = '" & customer_cost & "', customer_ac = '" & customer_ac & "', customer_sc = '" & customer_sc & "', reseller_cost = '" & reseller_cost & "', reseller_ac = '" & reseller_ac & "', reseller_sc = '" & reseller_sc & "' WHERE sequence = '" & sequence & "';" 

,但其采取的年龄,甚至没有完成。

ExecuteNonQuery()的说法:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 

这可能是导致它不完整?

我抄查询(正确的值),并试图直接大约需要49秒的服务器上运行(但实际完成)

我已经在表中添加一个索引我sequence

+1

您是否知道,如果客户说'Ziggy's Hardware',那么以这种方式创建SQL会崩溃?而且它强制这些成本项目串?使用SQL参数 – Plutonix

+1

你对换行符有什么作用? –

+0

@Plutonix客户列只有一个整数,所以永远不会有任何''' – charlie

回答

3

您可以尝试将CommandTimeout设置为更高的值。 Sql Server的默认值是30秒,我没有MySql的参考,但它可以相等。所以,如果你的命令在服务器上执行需要49秒,那么从你的代码中超时30秒,它肯定是一个炫耀者。

command.CommandTimeout = 60 

但是,让我警告你一个更大的问题在你的查询。这个查询可能很容易用Sql Injection方案攻击。最好尽快搜索参数化查询并更改编码习惯。

编辑对于Sql Server,MySqlCommand的超时时间为30秒。
Found a reference here

+0

如果您在使用时查看'MySqlConnectionStringBuilder.ConnectionTimeout',默认值为15 – Plutonix

+0

Uhm,但那是ConnectionTimeout而不是CommandTimeout – Steve

+0

Ack!对不起,我感到困惑。 – Plutonix