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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:33:26+00:00 2026-05-29T21:33:26+00:00

I declared my Array: Dim invoice_discountitems(100, 100) As String Set Values into array: For

  • 0

I declared my Array:

Dim invoice_discountitems(100, 100) As String

Set Values into array:

For i As Int16 = 0 To data_set.Tables("discount_items").Rows.Count - 1
    invoice_discountitems(i, 1) = data_set.Tables("discount_items").Rows(0).Item("item_code")
    invoice_discountitems(i, 2) = data_set.Tables("discount_items").Rows(0).Item("discountitem_average")
Next

Now I try to find a single value:

Dim res As String
res = Array.IndexOf(invoice_discountitems, "FO1506")
MsgBox(res)

But, I get this error 🙁

"Only single dimension arrays are supported here"
  • 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-29T21:33:28+00:00Added an answer on May 29, 2026 at 9:33 pm

    This is a fundamentally wrong approach – for a number of reasons

    • You’re treating ALL the data points as Strings
    • You’re not taking advantage of DB optimisations like indices
    • You’re loading data into memory that you’re never going to use (at least int he example)

    The Nicest way to do it would be with Linq-To-Entities:

    Dim Record = MyDBContext.Discount_Items.Where(function(x) x.ItemCode = "FO1506").Single
    Console.WriteLine(Record.discountitem_average);
    

    If you’re stuck with your current Data Access Layer, you need to modify the SQL being executed to only return the information you’re interested in. Without more information, I can’t provide decent example code but you want the SQL to end up looking like this…

    SELECT  itemcode,
            discountitem_average,
            [Other fields],
    FROM    MyDatabase.M
    

    EDIT: To Clarify, there are a number of ways to access data in a database. The one I prefer is LINQ-To-Entities (Have a look through this tutorial).

    In short, you add a new Item to your project and point it at your database. This becomes your “Database Context” – it represents the database and that’s how you run queries.

    Project -> Add -> New Item…

    Select ADO.Net Entity Data Model (Linq-To-Entities is almost Identical to Linq-To-Sql but more recent and better supported – use Entities until you know the difference)

    Call it something like MyDBContext

    When prompted, choose “Generate From Database” and point it at your database.

    It’s worth noting that the designer takes advantage of information in the database like Foreign Key Constraints – So the better your database is designed, the better the model it will create.

    Then, you refer to it in code as shown in my first example.

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

Sidebar

Related Questions

I Declared my Array like this: Dim invoice_discountitems(100, 1) As String Now i set
Dim arrS(1000, 6) As String Sub FromHere() '(I've already filled the array and just
Background: I needed to split a string of numerous words into an array which
I have declared an array in the form: var refs = { 'EE810': Presence
I have a C++ array declared as mentioned below: CString carray[] = { A,
In my code an array is declared as follows private Object[,] cellInfos = new
I have a simple function in which an array is declared with size depending
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
What is the best way to convert an array of bytes declared as TBytes
I am having some problems with manipulating a one dimensional string array in VB.NET

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.