Son varias lineas de codigo pero es en esta parte donde llamó al procedimiento almacenado, tmb chequeo el estado de la conexión, el timer1 se ejecuta cada 5 segundos
Private Sub ExecStoredProcedure()
Try
' conexion con TIMEOUT= 4seg
If sqlConnection.State = ConnectionState.Closed Then
sqlConnection.Open()
End If
' conexion con TIMEOUT= 3600 seg
If sqlConnection2.State = ConnectionState.Closed Then
sqlConnection2.Open()
End If
sqlCommand.Connection = sqlConnection
sqlCommand.CommandType = CommandType.StoredProcedure
sqlCommand.CommandText = "prcNIHoraServidor"
sqlCommand.ExecuteNonQuery()
lblCheckStatus.Visible = True
lblCheckStatus.Text = "Conectado"
lblCheckStatus.ForeColor = Color.Green
BtnGrabar.BackColor = Color.Transparent
BtnGrabar.Enabled = True
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, AcceptButton)
lblCheckStatus.Visible = True
lblCheckStatus.Text = "Desconectado"
lblCheckStatus.ForeColor = Color.Red
BtnGrabar.BackColor = Color.Red
BtnGrabar.Enabled = False
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ExecStoredProcedure()
'==================================================================================
'=========================eliminar los Console.WriteLine===========================
'==================================================================================
If sqlConnection.State = ConnectionState.Open Then
Console.WriteLine("=========================================Open=========================================")
ElseIf sqlConnection.State = ConnectionState.Closed Then
Console.WriteLine("=========================================Closed=========================================")
ElseIf sqlConnection.State = ConnectionState.Broken Then
Console.WriteLine("=========================================Broken=========================================")
End If
End Sub
me sale este mensaje de texto
saludos