i need to select the minimum auto-increment number, then select the id number for reference in selecting the student's info. here's what I've got:
strSQL = "SELECT min(number) from main_queue "
cmd = New MySqlCommand(strSQL, CONNECTION)
dr = cmd.ExecuteReader
If dr.HasRows Then
dr.Read()
Dim min As Integer
min = dr("min(number)")
strSQL = "SELECT idno_ from main_queue where number='" + min + "'"
cmd = New MySqlCommand(strSQL, CONNECTION)
If dr.HasRows Then
dr.Read()
Dim idnum As Integer
idnum = dr("idno_")
strSQL = "SELECT * from student_records where number='" + idnum + "'"
cmd = New MySqlCommand(strSQL, CONNECTION)
If dr.HasRows Then
dr.Read()
mon_name.Text = dr("name_")
mon_IDno.Text = dr("IDno")
End If
End If
End If
I'm getting a "Conversion from string "" to type 'Double' is not valid." error at line where i select the id number using the minimum auto-increment number as the reference.
Perhaps I don't understand correctly your database schema, but it seems that you could write it all in a single query
Dim strSQL = "SELECT * FROM student_records " & _
"where idNO = " & _
"(SELECT idno_ from main_queue where number= " & _
"(SELECT min(number) from main_queue))"
cmd = New MySqlCommand(strSQL, CONNECTION)
If dr.Read() Then
mon_name.Text = dr("name_")
mon_IDno.Text = dr("IDno")
End If
managed to make it work! here's my code
SELECT * from student_records where IDno in (select idno_ from main_queue where number in (SELECT min(number) as min_number from main_queue))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.