Since mycommand
is a OleDbCommand
mycommand.ExecuteReader
returns a OleDbDataReader
but mydata
is a MySqlDataReader
. So change mydata
to be also a OleDbDataReader
.
Dim mydata As OleDbDataReader = mycommand.ExecuteReader()
Side-note: you should use the Using
-statement to ensure that all unmanaged resources are disposed:
Using conn As New OleDb.OleDbConnection(connection)
Using mycommand As New OleDb.OleDbCommand("select * from alarm", conn)
conn.Open()
Using mydata = mycommand.ExecuteReader()
If mydata.Read Then
' ... '
End If
End Using
End Using
End Using