Simplemente te falta el método de ejecución. Depende del tipo de resultado que desee. Si solo desea el primer resultado de la consulta (primera fila y primera columna), use sqlcmd.ExecuteScalar()
.
Si desea todos los resultados, tendrá que cargarlos en MySqlDataReader usando el método sqlcmd.ExecuteReader()
Usando ExecuteReader()
:
Dim connect As New MySqlConnection("server=localhost; user id=root; password= ; database=ticketing_system;")
connect.Open()
Dim sqladapter As New MySqlDataAdapter
Dim sqlcmd As New MySqlCommand
Dim dr As MySqlDataReader
Dim dt As New DataTable
sqlcmd = New MySqlCommand("SELECT * complaint WHERE tran_no='" & lbltranno.Text & "'")
dr = sqlcmd.ExecuteReader()
dt.Load(dr)
'Useable datatable in dt variable...
connect.Close()
Usando ExecuteScalar()
:
Dim connect As New MySqlConnection("server=localhost; user id=root; password= ; database=ticketing_system;")
connect.Open()
Dim sqladapter As New MySqlDataAdapter
Dim sqlcmd As New MySqlCommand
Dim dr As String
Dim dt As New DataTable
sqlcmd = New MySqlCommand("SELECT [COLUMN NAME] complaint WHERE tran_no='" & lbltranno.Text & "'")
dr = sqlcmd.ExecuteScalar()
'dr now contains the value of [COLUMN NAME] for the first returned row.
connect.Close()