-1
我一直執行查詢「System.IndexOutOfRangeException」接着「System.Reflection.TargetInvocationException」
A first chance exception of type 'System.IndexOutOfRangeException' occurred in MySql.Data.dll
其次
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
當得到這個2個錯誤這是我執行我的查詢
Sub Get_Teller_Num(hardware_Add As String)
Check_DB_Con() 'Check if the connection is okay
SQL_Query = "SELECT teller_info.teller_num, service_info.service_num " _
& "FROM service_info " _
& "JOIN teller_info " _
& "ON service_info.service_id = teller_info.teller_id " _
& "WHERE teller_info.hardware_add = " & hardware_Add
Dim MySQL_CMD As New MySqlCommand(SQL_Query, MysqlConn)
Try
MySQL_CMD.Connection.Open()
MySQL_Reader = MySQL_CMD.ExecuteReader()
While MySQL_Reader.Read
teller_Num = MySQL_Reader("teller_info.teller_num")
service_Num = MySQL_Reader("service_info.service_num")
End While
MySQL_Reader.Close()
Catch myerror As MySqlException
Console.WriteLine("Failed to run query: " & myerror.Message)
Finally
MysqlConn.Close()
MysqlConn.Dispose()
End Try
End Sub
正如您所看到的,我加入了另一個表格,因此我可以獲得某些值。