我总是收到错误 "timeout expired. the timeout period elapsed prior ..... "
I am always getting error "timeout expired. the timeout period elapsed prior ..... "
有人知道如何在下面这段代码中添加连接超时吗?
我总是收到错误 "timeout expired. the timeout period elapsed prior ..... "
.
Private Sub FillToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillToolStripButton.Click
Try
Me.SpLastTransactionTableAdapter.Fill(Me.VoyagerDataSet2.spLastTransaction, VaraccountToolStripTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
您可以使用 SqlCommand.CommandTimeout 属性 设置在终止尝试执行命令并生成错误之前的等待时间。
请注意,SqlDataAdapter.SelectCommand 是 SqlCommand
在 Fill
到 select 期间使用的数据库记录,用于放置在 DataSet 中,因此您可以使用:
Me.SpLastTransactionTableAdapter.SelectCommand.CommandTimeout = 1000
Me.SpLastTransactionTableAdapter.Fill(Me.VoyagerDataSet2.spLastTransaction, VaraccountToolStripTextBox.Text)
有人知道如何在下面这段代码中添加连接超时吗?
我总是收到错误 "timeout expired. the timeout period elapsed prior ..... "
.
Private Sub FillToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillToolStripButton.Click
Try
Me.SpLastTransactionTableAdapter.Fill(Me.VoyagerDataSet2.spLastTransaction, VaraccountToolStripTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
您可以使用 SqlCommand.CommandTimeout 属性 设置在终止尝试执行命令并生成错误之前的等待时间。
请注意,SqlDataAdapter.SelectCommand 是 SqlCommand
在 Fill
到 select 期间使用的数据库记录,用于放置在 DataSet 中,因此您可以使用:
Me.SpLastTransactionTableAdapter.SelectCommand.CommandTimeout = 1000
Me.SpLastTransactionTableAdapter.Fill(Me.VoyagerDataSet2.spLastTransaction, VaraccountToolStripTextBox.Text)