I'm working on a program that has to continue functioning even if the SQL database isn't available. If the user has sufficient rights they can continue on using manually entered values.
The way I'm doing this it takes a very long time to fail before this can happen. Is there a way to quickly, or continually, determine if the SQL database is available so that I can avoid trying the stored procedure if it isn't?
Code:Dim tblSteps As DataTable = New DataTable Dim StepsBindingSource As New BindingSource Private Sub cmdExecuteSproc(ByVal SO_Number As String, ByVal Prev_SO_Number As String) Dim spSteps As New SqlCommand("sproc_shop_order_get_recipe1", cnPMSQL) spSteps.Parameters.AddWithValue("@int_shop_order", SO_Number) spSteps.Parameters.AddWithValue("@int_prev_so", Prev_SO_Number) spSteps.CommandType = CommandType.StoredProcedure Try Dim StepsAdapter As SqlDataAdapter = New SqlDataAdapter(spSteps) tblSteps.Clear() StepsAdapter.Fill(tblSteps) StepsBindingSource.DataSource = tblSteps Catch ex As Exception MessageBox.Show("Database not available" & Environment.NewLine & ex.Message) End Try End Sub




Reply With Quote