The question is: Is there any problem if i open the db connection once every 100 ms in a timer? I think the best way is to open once the connection and then do the query all the times needed. Right?
My code is:
Friend conexion As MySqlConnection
Private cmd As New MySqlCommand
Private dr As MySqlDataReader
Private ConnectionString = "server=localhost; uid=root; pwd=; database=myblahdb;"
conexion = New MySqlConnection()
conexion.ConnectionString = ConnectionString
conexion.Open()
Dim cmd As New MySqlCommand
With cmd
.CommandText = "select blah blah"
.CommandType = CommandType.Text
.Connection = conexion
End With
dr = cmd.ExecuteReader
If dr.HasRows Then
dr.Read()
//do stuff
End If
cmd.Dispose()
dr.Close()
dr.Dispose()
conexion.Close()
conexion.Dispose()