Hello All,
I have a project im working on which is causing me to have to check a SQL database for any new records comming into a table in the last 2 minutes, and using that record count to activate a timer control in my application which will cause an item to blink in the system tray. I have the following code in which the SQL statement is working fine what i need to know is after i run this statement how i can check the recordcount and if its > 0 enable a timer on a form. All help is much appreciated :
I have a project im working on which is causing me to have to check a SQL database for any new records comming into a table in the last 2 minutes, and using that record count to activate a timer control in my application which will cause an item to blink in the system tray. I have the following code in which the SQL statement is working fine what i need to know is after i run this statement how i can check the recordcount and if its > 0 enable a timer on a form. All help is much appreciated :
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim myCommand As New SqlCommand
Dim myConnection As SqlConnection
myConnection = New SqlConnection(csNK1)
myConnection.Open()
With myCommand
.CommandType = CommandType.Text
.Connection = myConnection
.CommandText = "select count(*) from cnEventLog WHERE IncidentTime BETWEEN DATEADD(MI, -2, GETDATE()) AND GETDATE()"
End With
myCommand.ExecuteScalar()
Catch ex As Exception
MsgBox(ex.Message)
Return
End Try
End Sub
Last edited: