I have this function that return specific info of student from database. Here's the code.
Public Function arrInfo(Byval id as String)
Dim name as String = ""
DBCon_Open()
Dim Cmd = New MySqlCommand("SELECT * FROM student WHERE student_id ='" & id & "'", con)
Cmd.CommandTimeout = 0
Dim rs = Cmd.ExecuteReader
Do While rs.Read
name = rs.Item("firstname")
Loop
rs.Close()
Cmd.Dispose()
DBCon_Close()
Return name
End Function
MsgBox(arrInfo("STUD0027"))
Result: Ben
But, I want to return an array of info of a student from the query.
When I call the function it goes something like this:
MsgBox(arrInfo("STUD0027").("lastname"))
I tried this one but not working.
Public Function arrInfo(Byval id as String)
DBCon_Open()
Dim Cmd = New MySqlCommand("SELECT * FROM student WHERE student_id ='" & id & "'", con)
Cmd.CommandTimeout = 0
Dim rs = Cmd.ExecuteReader
rs.Close()
Cmd.Dispose()
DBCon_Close()
Return rs.Read
End Function
How can I achieve this array return?
Any help very much appreciated.
Thanks