Tôi đã giải quyết vấn đề này dễ dàng. Tôi đã đi vào mã thiết kế của tập dữ liệu (dataset1.designer.vb
) và tìm thấy các lệnh sau, Me._commandCollection(0)
, Me._commandCollection(1)
đến Me._commandCollection(5)
, bởi vì tôi có năm lệnh tổng thực thi dựa trên cơ sở dữ liệu SQL Server 2008 của tôi. Trong mỗi (0 đến 5) của các lệnh này tôi đã viết Me._commandCollection(0).CommandTimeout = 60
, trong đó tôi thay đổi 0 thành số tiếp theo cho bốn lệnh khác. Mỗi một trong năm lệnh có một khối mã, trong đó có hai khối xuất hiện bên dưới để cung cấp cho bạn một ví dụ.
Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(5) {}
Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand()
Me._commandCollection(0).Connection = Me.Connection
Me._commandCollection(0).CommandTimeout = 60
Me._commandCollection(0).CommandText = "SELECT MK_QR_SUB_AND_DETAIL.*" & _ "Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)" & _ "FROM MK_QR_SUB_AND_DETAIL"
Me._commandCollection(0).CommandType = Global.System.Data.CommandType.Text
Me._commandCollection(1) = New Global.System.Data.SqlClient.SqlCommand()
Me._commandCollection(1).Connection = Me.Connection
Me._commandCollection(1).CommandTimeout = 60
Me._commandCollection(1).CommandText = "dbo.spQtrRptTesting_RunInserts_Step1of4"
Me._commandCollection(1).CommandType = Global.System.Data.CommandType.StoredProcedure
Me._commandCollection(1).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@RETURN_VALUE", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me._commandCollection(1).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@pStartADate", Global.System.Data.SqlDbType.[Date], 3, Global.System.Data.ParameterDirection.Input, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me._commandCollection(1).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@pEndADate", Global.System.Data.SqlDbType.[Date], 3, Global.System.Data.ParameterDirection.Input, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me._commandCollection(1).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@pStartBDate", Global.System.Data.SqlDbType.[Date], 3, Global.System.Data.ParameterDirection.Input, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me._commandCollection(1).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@pEndBDate", Global.System.Data.SqlDbType.[Date], 3, Global.System.Data.ParameterDirection.Input, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Đúng, nhưng đó là những gì tôi đang cố gắng tránh làm ... Cá nhân rất dễ làm ... Nếu bạn có vài trăm bộ điều hợp bảng cho hàng trăm bộ dữ liệu thì nó thực sự không khả thi lắm. – Gary
Tôi không thể nghĩ bạn có thể làm gì khác. Không có tài sản CommandTimeout toàn cầu. Nếu có, nó sẽ bằng cách nào đó phải thiết lập các thuộc tính SqlCommand.CommandTimeout riêng lẻ. –
Tại sao người ta không thể điều chỉnh thuộc tính CommandTimeout trong Nhà thiết kế Dataset? Và tại sao nó vẫn còn 30 giây khi tôi thay đổi Thời gian chờ kết nối thành 300 giây? Btw, sự khác nhau giữa chúng là gì? Cảm ơn trước ... –