Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:54+00:00 2026-05-26T15:09:54+00:00

what is wrong with my code? Dim x As Integer Dim sql As String

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:09:55+00:00Added an answer on May 26, 2026 at 3:09 pm
    1. You’re not using parameterized queries
    2. There is a space character after ‘checkin ‘, which may not be in the database, so there’s no match
    3. You’re not using the room number as a parameter to the SQL query
    4. Most importantly: you’re not telling us what the error is!

    I can see that you’re writing no_room='x'. This checks whether there is an ‘x’ character in the column no_room of your database.

    If you want to check whether the room with the number of x is already in the database, you should use

    cmd = New SqlCommand("SELECT * FROM tTransaction WHERE no_room = @roomNumber AND status = 'checkin'", conn)
    cmd.Parameters.AddWithValue("@roomNumber", x)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

what is wrong with such code public List<SearchItem> Search(string find) { return (from i
What is wrong here in the code Dim sReaderList As String sReaderList = New
What is wrong with this code ? set<string> nk ; bitset<3> bs1(string(100)); nk.insert(bs1.to_string()); error:
I have the following code: Dim i As Integer = dtResult.Rows.Count For i =
Public Sub EdgeColor_Click() Dim intInFile As Integer intInFile = FreeFile Open c:\picturename.csv For Output
Would it be wrong if write the following code Sub Something() Dim i As
This is the code: Dim dr() As DataRow = DataSet.Tables(TableName).Select(EVENTNAME = ' & name
The following code produces wrong and inconsistent output with gcc (4.1.2 20080704) but correct
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
what's wrong with my code? i want spinner indicator start when view1.nib start to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.