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

  • Home
  • SEARCH
  • 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 8005559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:15:44+00:00 2026-06-04T17:15:44+00:00

tl;dr Method of copying contents of an SQL query to an array or a

  • 0

tl;dr Method of copying contents of an SQL query to an array or a string or a listbox. Single columns, multiple rows.

Working on a small project for some extra course credit.
Developing it currently in Visual Studio 2010.
Essentially is an interactive menu where users select items and can add them to an inbuilt
list and it will calculate total nutritional information and costs etc..

I’m having an issue however. When the user reaches the order builder page they can select the type of item they wish to buy.

E.G.

Beef

Clicking this should then populate a list box with all the related items.

I’m hoping to do this via a database connection.
I currently have an embedded database.

Their where 2 ways I’ve tried to do this but both proved unsuccessful or perhaps I’m just doing it wrong.

First method.

 Dim index As Integer = 0
    Dim length As Integer = adapter.productscounter()
    ' Small query that works out total number of rows.

    For index = 0 To length
        ListBox1.Items.Add(adapter.SelectBeef(index))


    Next

This gives me the error:

There is no row at position 0.

which I seem unable to solve. The query runs upon trial execution and theirs something their.

Index out of range exception

The other method I was attempting was similar code however using an array and then copying the contents of that into the listbox.

    Dim index As Integer
    Dim test(5)
    Dim length As Integer = adapter.productscounter()
    Dim counter As Integer


    For index = 0 To length

        test(index) = adapter.SelectChicken()
        counter = counter + 1

    Next


    For counter = 0 To length
        ListBox1.Items.Add(test(index))

    Next

Generates:

Argument nullexception 

Value cannot be null.
Parameter name: item.
  • 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-04T17:15:45+00:00Added an answer on June 4, 2026 at 5:15 pm

    In Visual Basic, the standard is to start a list with element 1, not element 0. You could try:

    For index = 1 To length
        ListBox1.Items.Add(adapter.SelectBeef(index))
    Next
    

    Though of course, I have no insight in what the SelectBeef method does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive written the following method which sorts an array by copying the biggest values
I found a method for copying ntfs permissions information from one existing folder to
I have created a method that takes two Collection<String> as input and copies one
I have a python method that returns a Python byte array.array('c'). Now, I want
I am copying the contents of an Excel file onto the Clipboard within a
I normally make multiple small edits to my source code, but I don't want
in my iPhone projects, I am currently copying files using NSFileManager 's -copyItemAtPath:toPath:error: method.
UPDATE 2009-05-21 I've been testing the #2 method of using a single network share.
I'm having problem with a copying method in a simple C++ program. Everytime I
I have the following method of copying files: public static void nioCopy(File source, File

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.