none
SqlCommand Timeout RRS feed

  • Question

  • I have a question regarding the Timeout property of the SqlCommand class (I'm actually using MySqlCommand, but I'm assuming it is the same). If I set the timeout to 10 seconds, for example, does that mean that it will wait up to 10 seconds for the query's result to start arriving before timing out, or does it mean that the entire result must arrive, in it's entirety, within the 10 seconds?

    If the second one is the case -which I think it is - is there a way to set a timeout to work on a "packet" level? So that the command object waits up to x seconds for data to arrive. But as long as data is continuously arriving (or within the specified x second timeout) it will not time out? In other words, thinks of a timer that starts on 0 seconds - as soon as the query is executed - and starts counting. Every time any data packet arrives from the database server, the command object resets the timer. If no data packets arrive for x seconds, the timer will trigger a timeout. Is something like that possible?


    Fabricio Rodriguez Pretoria, South Africa

    Monday, November 4, 2013 2:34 PM

Answers

  • Hello,

    The sqlcommand timeout property is used to get or set the wait time before terminating the attempt to execute a command and generating an error.

    So it is the first meaning. It will wait the time from sending command to database and execute it and then return the result.

    If we set it to be 30s, then after 30s, whether it has already found out the result and on the way to the program or not, it will throw the timeout error.

    For detail information, you can check link below:

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fabs1977 Tuesday, November 5, 2013 7:46 AM
    Tuesday, November 5, 2013 7:29 AM
    Moderator

All replies

  • Hi Fabs,

    I think this thread is specific to Data forum. This form is to discuss problems about CLR development. So I am helping you to move this thread directly into that forum. Thank you for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 5, 2013 4:34 AM
    Moderator
  • Oops, sorry about that. Thanks for moving the thread for me.

    Fabricio Rodriguez Pretoria, South Africa

    Tuesday, November 5, 2013 6:37 AM
  • Hello,

    The sqlcommand timeout property is used to get or set the wait time before terminating the attempt to execute a command and generating an error.

    So it is the first meaning. It will wait the time from sending command to database and execute it and then return the result.

    If we set it to be 30s, then after 30s, whether it has already found out the result and on the way to the program or not, it will throw the timeout error.

    For detail information, you can check link below:

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fabs1977 Tuesday, November 5, 2013 7:46 AM
    Tuesday, November 5, 2013 7:29 AM
    Moderator
  • Thanks for the reply. Yeah, I suspected that was the case. What would be nice is a timeout that works on a packet level, where as long as data is arriving, it will not timeout. But if no data arrives for X seconds, then it times out. Oh well...

    Fabricio Rodriguez Pretoria, South Africa

    Tuesday, November 5, 2013 7:47 AM