tags:

views:

120

answers:

3

I'm using SqlClient.SqlCommand object to run a few stored procs on my db. Normally when I run these manually via Query Analyzer they take up to 15 minutes to complete.

So obviously when I run them using the SqlCommand object I get a SqlCommand timeout.

I know I could set the timeout property to a very high number, but I'm wondering if alternatively there's a way to just kickoff the procs and disconnect. I don't need a return value.

Any suggestions? I'm not interested in optimizing the processing time of each sp here, just trying to determine if there's a 'set it and forget it' option.

Here's the content of the SqlCommand object:

using (SqlCommand cmd = new SqlCommand(@"update tbl_SYS_DATE set RPT_DATE = @inputDate
                                                    exec sp_Get_Bp_Data1
                                                    exec sp_Get_Bp_Data2          
                                                    exec sp_Get_Bp_Data3
                                                    exec sp_channel_data1
                                                    exec sp_channel_data2
                                                    exec sp_channel_data3
                                                    ", con))
A: 

You could run that code from a background thread. You could look into the BackgroundWorker object.

Eclipsed4utoo
+3  A: 

You can use an async method, like BeginExecuteNonQuery. The timeout is ignored for that.

Jason
+1 - beat me by 22 seconds (but no link, so who really won?:-) )
Harper Shelby
well to be fair, I did read that page to check my answer. :)
Jason
+2  A: 

Use the asynchronous method call BeginExecuteNonQuery. From the MSDN page

The CommandTimeout property will be ignored during asynchronous method calls such as BeginExecuteReader.

Harper Shelby