Select case ,正确的格式是什么

Select case , what is the right format

我一直在研究如何将值插入我的文本框中,以便我可以在我的数据库中找到它。所以我可以以结果结束。

(Table name = rooms)
(Table contents = Roomnumber,Status,Roomtype)
(Roomnumber = 201,202,203)
(Status= Available,Occupied,Reserved)

这是我的代码:

myConnection.Open()
Dim cmd As New OleDbCommand("Select  [Roomnumber] = '" & textboxt1.text & "' ,[Status] FROM [rooms]", myConnection)
Dim dt As New DataTable
dt.Load(cmd.ExecuteReader)

For Each row As DataRow In dt.Rows

    Select Case row("Roomnumber").ToString()

        Case "textbox1.text"
            Select Case row("Status").ToString().ToLower()

                Case "available"
                    Msgbox("hello")

                Case "occupied"
                    Msgbox ("hi")

                Case "reserved"
                    Msgbox ("input code")

            End Select
    End Select
Next
myConnection.Close()

End Sub

我希望我的房间号取决于文本框中的内容,并在数据库中查找其状态。我的错误是我把 "textbox.text"

我找到了解决方案,我更改了 "cmd"

的格式

正确代码如下:

myConnection.Open()
Dim cmd As New OleDbCommand("Select  [Roomnumber] ,[Status] FROM [rooms] WHERE Roomnumber = " & textbox1.text & "", myConnection)
Dim dt As New DataTable
dt.Load(cmd.ExecuteReader)

For Each row As DataRow In dt.Rows

Select Case row("Roomnumber").ToString()

    Case "textbox1.text"
        Select Case row("Status").ToString().ToLower()

            Case "available"
                Msgbox("hello")

            Case "occupied"
                Msgbox ("hi")

            Case "reserved"
                Msgbox ("input code")

        End Select
End Select
Next
    myConnection.Close()

End Sub