本文介绍了SQLREADER中异常的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim sqlselect As String
sqlselect = " SELECT trpbus_seatno FROM trpbus_bookdata where trpbus_date='" & textbox_date.Text & "' and trpbus_time = '" & Label_deptime.Text & "'"
Dim myConnection As New SqlConnection(Utility.CurrentConnectionString)
Dim myCommand As New SqlCommand(sqlselect, myConnection)
myConnection.Open()
Dim myReader As SqlDataReader
myReader = myCommand.ExecuteReader()
If myReader.HasRows Then
While myReader.Read()
Dim seat As String = (myReader("seat")).ToString() <----ERROR UNHANDLED EXCEPTION
If seat = "S-1" Then
ImageButton_seat_1.ImageUrl = seatno_booked
ElseIf seat = "S-2" Then
ImageButton_seat_2.ImageUrl = seatno_booked
ElseIf seat = "S-3" Then
ImageButton_seat_3.ImageUrl = seatno_booked
ElseIf seat = "S-4" Then
ImageButton_seat_4.ImageUrl = seatno_booked
End If
End While
End If
myReader.Close()
推荐答案
Dim seat As String = (myReader("trpbus_seatno")).ToString()
(myReader("seat")).ToString() replace this line by
(myReader("trpbus_seatno")).ToString()
希望它的工作
祝你好运
快乐编码:)
Hope its work
Best Luck
Happy Coding:)
这篇关于SQLREADER中异常的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!