How can I change the table adapter's command timeout

后端 未结 15 1464
遇见更好的自我
遇见更好的自我 2020-12-10 02:12

I\'m using Visual Studio 2008 with C#.

I have a .xsd file and it has a table adapter. I want to change the table adapter\'s command timeout.

Thanks for your

15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 02:49

    Here's some example code from MSDN, using VB.NET:

    Imports System.Data.SqlClient
    Namespace MyDataSetTableAdapters
        Partial Class CustomersTableAdapter
            Public Sub SetCommandTimeOut(ByVal timeOut As Integer)
                For Each command As SqlCommand In Me.CommandCollection
                    command.CommandTimeout = timeOut
                Next
            End Sub
        End Class
    End Namespace
    

    When it comes time to call a long query, just call the SetCommandTimeOut method before the query:

    Dim ds As New MyDataSet
    Dim customersTA As New MyDataSetTableAdapters.CustomersTableAdapter
    ' Increase time-out to 60 seconds
    customersTA.SetCommandTimeOut(60000)
    ' Do the slow query
    customersTA.FillSlowQuery(ds.Customers)
    

提交回复
热议问题