CommandTimeout doesn't apply to fetching data - is affects just command
execution.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group
www.codezone-si.info
"Brad" <(E-Mail Removed)> wrote in message
news:FA7CD885-B05B-45E7-9B6D-(E-Mail Removed)...
> When I set the Timeout property of a command I am executing it does not
> end
> when it reaches the timeout value specified. Here is the code I am using.
> My
> sample query is simply returning all rows from a table with approximately
> 170,000 rows. The dataadapter.Fill takes between 8 and 10 seconds.
>
> Dim cnn As SqlConnection
> Dim cmd As SqlCommand
> Dim da As SqlDataAdapter
> Dim ds As DataSet
> Dim datStartTime As DateTime
> Dim datEndTime As DateTime
>
> Try
> cnn = New SqlConnection
> cmd = New SqlCommand
> da = New SqlDataAdapter
> ds = New DataSet
>
> cnn.ConnectionString = " - Removed for security reasons - "
> cnn.Open()
>
> cmd.Connection = cnn
> cmd.CommandTimeout = 2
> cmd.CommandText = " - Removed for security reasons - "
> cmd.CommandType = CommandType.Text
>
> da.SelectCommand = cmd
> datStartTime = Now
> da.Fill(ds)
> datEndTime = Now
> Me.txtDuration.Text =
> datEndTime.Subtract(datStartTime).TotalSeconds.ToString & " seconds"
>
> Me.DataGrid1.DataSource() = ds.Tables(0)
>
> Catch ex As Exception
> MessageBox.Show(ex.ToString)
>
> Finally
> If Not cmd Is Nothing Then
> cmd.Dispose()
> End If
> If Not cnn Is Nothing Then
> cnn.Dispose()
> End If
> End Try
>
>