what is wrong with my code?
Dim x As Integer
Dim sql As String
ModConnectDb.OpenDatabase()
conn.Open()
For x = 200 To 208
sql = "select * from ttransaction where no_room= 'x' and status= 'checkin '"
cmd = New SqlCommand(sql, conn)
dtReader = cmd.ExecuteReader
If dtReader.HasRows = False Then
cbo_numberroom.Items.Add(x)
End If
dtReader.Close()
Next
I’m making an application for the hospital. VIP room has an room number 200 to 208
purpose of this code is. if radio button is selected who is a VIP, he will check whether the number 200 is already in the database and whether the status of the room checkin. if yes, then the number 200 will not appear in the combobox noRoom again.
but the results of this code. although the 200 has been filled, still appear in the combobox to select the room number
I really hope that help
Thank You Before
I can see that you’re writing
no_room='x'. This checks whether there is an ‘x’ character in the columnno_roomof your database.If you want to check whether the room with the number of
xis already in the database, you should use