Ho risolto facilmente questo problema. Sono entrato nel codice del mio set di dati del dataset (dataset1.designer.vb
) e ho trovato i seguenti comandi, Me._commandCollection(0)
, Me._commandCollection(1)
a Me._commandCollection(5)
, perché ho cinque comandi totali eseguiti contro il mio database SQL Server 2008. In ciascuno (da 0 a 5) di questi comandi ho scritto Me._commandCollection(0).CommandTimeout = 60
, dove cambio 0 al numero successivo per gli altri quattro comandi. Ognuno dei cinque comandi ha un blocco di codice, di cui due sotto appaiono per fornirti un esempio.
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, "", "", ""))
Giusto, ma questo è quello che sto cercando di evitare di fare ... Singolarmente è facile da fare ... Se hai diverse centinaia di adattatori da tavolo per diverse centinaia di set di dati non è davvero molto praticabile. – Gary
Non riesco a pensare a cos'altro potresti fare. Non esiste una proprietà CommandTimeout globale. Se esistesse, sarebbe comunque in qualche modo necessario impostare le singole proprietà SqlCommand.CommandTimeout. –
Perché non è possibile regolare la proprietà CommandTimeout in Dataset Designer? E perché sono ancora 30 secondi quando cambio Timeout connessione a 300 secondi? A proposito, qual è la differenza tra questi? Grazie in anticipo ... –