Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

mysql - vb.net SQL update query cannot completed

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.

on the ExecuteNonQuery() its saying:

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?

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)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...