SQLREADER中异常的异常 [英] UNHANDLED EXCEPTION IN SQLREADER

查看:85
本文介绍了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()

推荐答案


用以下代码替换您的代码:

replace your code with this :
Dim seat As String = (myReader("trpbus_seatno")).ToString()




我认为您的代码中有错误
Hi,

I think Error in Your code
(myReader("seat")).ToString() replace this line by
(myReader("trpbus_seatno")).ToString()


希望它的工作
祝你好运
快乐编码:)


Hope its work
Best Luck
Happy Coding:)


这篇关于SQLREADER中异常的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆