vb.net SQL 更新查询无法完成 [英] vb.net SQL update query cannot completed

查看:40
本文介绍了vb.net SQL 更新查询无法完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 vb.net 应用程序中执行此更新查询:

i am trying to execute this update query in a vb.net application:

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 & "';"

但它需要很长时间,甚至还没有完成.

but its taking ages and not even completing.

关于 ExecuteNonQuery() 的说法:

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

什么可能导致它无法完成?

what could be causing it to not complete?

我已经复制了查询(使用正确的值)并尝试直接在服务器上运行,这需要大约 49 秒(但它实际上已完成)

i have copied the query (with the correct values) and tried to run directly on the server which takes about 49 secs (but it actually completes)

我在表中的 sequence 列上添加了索引

i have added an index on my sequence column in the table

推荐答案

您可以尝试将 CommandTimeout 设置为更高的值.Sql Server 的默认值为 30 秒,我没有对 MySql 的参考,但它可能相等.因此,如果您在服务器上执行的命令需要 49 秒,那么您的代码的超时时间为 30 秒,这肯定是个难题.

You could try to set the CommandTimeout to an higher value. The default is 30 seconds for Sql Server, I have no reference for MySql but it could be equal. So, if your command executed on the server takes 49 seconds, then a Timeout of 30 seconds from your code it is surely a showstopper.

 command.CommandTimeout = 60

但是,让我警告您查询中存在更大的问题.使用 Sql 注入方案可以轻松破解此查询.最好尽快搜索参数化查询并改变您的编码习惯.

However let me warn you about a bigger problem in you query. This query could be easily hacked with an Sql Injection scheme. It is better that you search as soon as possible for Parameterized queries and change you coding habits.

编辑 MySqlCommand 的超时时间为 30 秒,与 Sql Server 一样.
在这里找到参考

EDIT The Timeout for a MySqlCommand is 30 seconds as for Sql Server.
Found a reference here

这篇关于vb.net SQL 更新查询无法完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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