我一直在尝试执行存储过程,但每次单击从我的应用程序执行它时,都会超时并出现以下错误:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
任何想法,如果有什么需要改变下面的例程?
Private Sub Reset()
Dim connectionString As String = ConfigurationManager.ConnectionStrings("constring").ConnectionString
Dim storedProcName As String = "insertnewSP"
Dim conn As SqlConnection = New SqlConnection(connectionString)
conn.Open()
Dim command As SqlCommand = New SqlCommand(storedProcName, conn)
command.CommandType = CommandType.StoredProcedure
command.ExecuteNonQuery()
command.Dispose()
conn.Close()
conn.Dispose()
End Sub
Protected Sub Refresh_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Refresh.Click
' Clean up text to return the Gridview to it's default state
Reset()
strsearch.Text = ""
SearchString = ""
gridView1.DataBind()
End Sub
非常感谢
答案 0 :(得分:0)
您的CommandTimeout可能在呼叫完成之前到期,请尝试以下操作:
Private Sub Reset()
Dim connectionString As String = ConfigurationManager.ConnectionStrings("constring").ConnectionString
Dim storedProcName As String = "insertnewSP"
Dim conn As SqlConnection = New SqlConnection(connectionString)
conn.Open()
Dim command As SqlCommand = New SqlCommand(storedProcName, conn)
command.CommandType = CommandType.StoredProcedure
command.CommandTimeout = 180
command.ExecuteNonQuery()
command.Dispose()
conn.Close()
conn.Dispose()
End Sub
Protected Sub Refresh_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Refresh.Click
' Clean up text to return the Gridview to it's default state
Reset()
strsearch.Text = ""
SearchString = ""
gridView1.DataBind()
End Sub