Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Timer Control


Timer Control

Author
Message
Benniit
Benniit
Forum God
Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)Forum God (4.7K reputation)

Group: Forum Members
Posts: 29, Visits: 825
The code below loops through all the records and checks if Allocation_Due_Date is equal to the current date. If a match is found, the tooltip displays it on a button on the form. My problem is a time will come and the records will be many which will cause the machine to hang. So if someone can help me place the below code in a thread to free the machine from hanging. Thank you



' The sub procedure 'AllocationExpiryDate' is called to the Tick event of the timer control.



Public Sub AllocationExpiryDate()

Dim SQLCon As New SqlConnection : Dim dtTable As New DataSet

strUsername = GetSetting("Allocation", "Connection", "DataL1")

strPassword = GetSetting("Allocation", "Connection", "DataL2")

strServerName = GetSetting("Allocation", "Connection", "DataL3")

strInitialCatalog = GetSetting("Allocation", "Connection", "DataL4")

DataL1 = strUsername & strPassword & strServerName & strInitialCatalog

SQLCon.ConnectionString = DataL1

Try

SQLCon.Open()

Dim Query As String = "Select * from Alloc order by Allocation_Due_Date asc"

daAdapter = New SqlDataAdapter(Query, SQLCon)

daAdapter.Fill(dtTable, "Alloc")

Dim table As DataTable = dtTable.Tables("Alloc")

If table.Rows.Count > 0 Then

Dim ctr As Integer

For ctr = 0 To table.Rows.Count - 1

Dim dtAllocExpDate = FormatDateTime(table.Rows(ctr).Item("Allocation_Due_Date").ToString.Trim, DateFormat.ShortDate)

If dtAllocExpDate = Now Then Then

frmMainForm.ToolTip1.Show("Allocation note is due for revision. Refer to the allocation list", frmMainForm.btnExpiry)

End If

Next

End If

Catch ex As Exception

MsgBox(Err.Description)

End Try

End Sub

Ben
Mod
Mod
Moderator
Moderator (14K reputation)

Group: Moderators
Posts: 78, Visits: 255
I hope this is of help,



http://msdn.microsoft.com/en-us/library/windows/desktop/dd744765%28v=vs.85%29.aspx


Regards,

Forum Moderator

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search