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 9188429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:00:21+00:00 2026-06-17T20:00:21+00:00

I am trying to run a simple query that returns three columns but am

  • 0

I am trying to run a simple query that returns three columns but am running into an error stating that the data does not exist though I am quite certain it does.

This is the section of code in question.

        cmd.CommandText = "SELECT school.id, school.city, school.state 
                           FROM school,city
                           WHERE school.name = '" & SchoolLb.SelectedItem & "'
                           AND city.name = '" & CityLb.SelectedItem & "';"

        'MessageBox.Show(cmd.ExecuteScalar)
        myReader = cmd.ExecuteReader
        profileSchool = myReader(0)
        profileCity = myReader(1)
        profileState = myReader(2)

The School list box is populated with schools located in the city that is currently selected in the city list box, so they match up. When I remove the comment tag from MessageBox.Show(cmd.ExecuteScalar) the ExecuteScalar runs and returns a message showing the ID of the correct record. However when using cmd.ExecuteReader I get the error mentioned above.

Thanks for looking.

  • 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-06-17T20:00:22+00:00Added an answer on June 17, 2026 at 8:00 pm

    You need to execute the reader and then advance it to the next record by using reader.Read():

    Using reader = cmd.ExecuteReader()
        reader.Read()
        profileSchool = reader(0)
        profileCity = reader(1)
        profileState = reader(2)
    End Using 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a simple query with $this->db in Kohana, but am running
I'm trying to write a simple Ubiquity command that will run a query on
I'm trying to run a query on a very simple table but I'm not
I'm trying to run a simple query with PDO in PHP. The code is
I have a very simple query that I am trying to optimize. issues_notes is
I'm trying to run a simple insert query to a database. I have it
I am trying to run a SQL query that will update information in a
I'm trying to run a query that checks if some conditions are true and
I'm trying to run this simple query: try { $dsn = mysql:host=localhost;dbname:mydb; $PDO =
I am trying to run a simple FQL query: SELECT aid,name FROM album WHERE

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.