dragonflare
Member
- Joined
- Oct 11, 2011
- Messages
- 6
- Programming Experience
- 1-3
Hey there all,
Basically i am making a software that will be interacting with a database (sql). Now ... what i wanted is a loop which after every 30 minutes, connects to the database finds some info and executes a bunch of statements...
For the sake of testing i have made the timer tick at 1 second, and display a record in a database in a label continuously just to see if it works (i will later make the tick 30 min)
Now this is what i have tried till now , it prints the record in database perfectly after 5 seconds, but after that just fails.
I want to infinitely make a loop in which after every 30 minutes has passed it would connect to the database get a record and then use the value of that record to perform some operations. And this has to be done in the background...
Any ideas where i am going wrong?
Thanks for all help!
Basically i am making a software that will be interacting with a database (sql). Now ... what i wanted is a loop which after every 30 minutes, connects to the database finds some info and executes a bunch of statements...
For the sake of testing i have made the timer tick at 1 second, and display a record in a database in a label continuously just to see if it works (i will later make the tick 30 min)
Now this is what i have tried till now , it prints the record in database perfectly after 5 seconds, but after that just fails.
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
times = 5
For i As Integer = 0 To 5 Step 1
DataCheckTimer.Start()
Next
End Sub
Private Sub DataCheckTimer_Tick() Handles DataCheckTimer.Tick
If times > 0 Then
times -= 1
Else
DataCheckTimer.Stop()
call Infinite()
End If
End Sub
Public Sub Infinite()
Try
Dim test As String = ""
Dim query As String = "SELECT pc FROM main"
Dim connection As New MySqlConnection(connStr)
Dim cmd As New MySqlCommand(query, connection)
connection.Open()
Dim reader As MySqlDataReader
reader = cmd.ExecuteReader()
While reader.Read()
test = reader.GetString(0)
End While
reader.Close()
connection.Close()
lbl.Text = lbl.Text & test
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
I want to infinitely make a loop in which after every 30 minutes has passed it would connect to the database get a record and then use the value of that record to perform some operations. And this has to be done in the background...
Any ideas where i am going wrong?
Thanks for all help!