Managing TableAdapter Command Timeouts

| No TrackBacks

No, the folks that built the Data Source configuration wizard that generates TableAdapter classes did not see fit to include the ability to set the CommandTimeout property for the numerous SELECT and DML Command objects they build for you.

To address this issue you’ll need to implement a Partial Class to create your own properties.

Here’s a hint—the rest of the code is in an upcoming article…

Namespace NorthWind2008DataSetTableAdapters
    Partial Public Class CustomersTableAdapter
               Public Property SelectCommandTimeout() As Integer
            Get
                Return (Me.Adapter.SelectCommand.CommandTimeout)
            End Get
            Set(ByVal value As Integer)
                ' Note that Me.Adapter.SelectCommand might not exist
                ' Reference to CommandCollection(0)
                '  might trigger creation of CommandCollection
                If Me.CommandCollection(0) Is Nothing Then
                    ' CommandCollection not created
                    ' Probably should throw an exception here...
                Else
                    ' SelectCommand is created from the CommandCollection
                    Me.CommandCollection(0).CommandTimeout = value
                End If
            End Set
        End Property

    End Class
End Namespace

 

No TrackBacks

TrackBack URL: http://betav.com/blogadmin/mt-tb.cgi/2355

Pages

Powered by Movable Type 4.21-en

About this Entry

This page contains a single entry by William Vaughn published on February 23, 2009 4:20 PM.

New Express Version of SQL Server Management Studio was the previous entry in this blog.

Drillthrough Reports with the ReportViewer is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.