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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:16:56+00:00 2026-06-08T13:16:56+00:00

Dim sql As String = Select ProductID From OrderDetail Order By ProductID Desc Dim

  • 0
Dim sql As String = "Select ProductID From OrderDetail Order By ProductID Desc"
    Dim command As New SqlCommand(sql, connection)
    Dim reader1 As SqlDataReader = command.ExecuteReader()

How do i store all the productid that i have retrieve into an array?

  • 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-08T13:16:58+00:00Added an answer on June 8, 2026 at 1:16 pm
    Dim list As New List(Of Integer)
    
    Using reader As SqlDataReader = command .ExecuteReader()
        While reader.Read()
            list.Add(reader.GetInt32(reader.GetOrdinal("ProductID")))
        End While
    End Using
    'check  list.ToArray() now
    

    EDIT : But, Instead of return an Array, i Would return a Generic List of Integers (if you only want to return the ProductId) or A List of ProductClass objects

    Private Function GetProductIDs() As IList(Of Integer)
    
        Dim list As New List(Of Integer)
        Dim conStr = "write your connection string here"
    
        Using connection As New SqlConnection(conStr )
            Dim sql As String = "Select ProductID From OrderDetail Order By ProductID Desc"
            Dim command As New SqlCommand(sql, connection)
            Using reader As SqlDataReader = command.ExecuteReader()
                While reader.Read()
                    list.Add(reader.GetInt32(reader.GetOrdinal("ProductID")))
                End While
            End Using
        End Using
    
        Return list
    
    End Function
    

    EDIT 2 : As per the comment,
    To retrieve an put in the Text of a label, you can do this

    Dim str As String
    str = String.Join(",", GetProductIDs())
    Label1.Text=str;
    

    Assuming Label1 is theI D of your label control.The String.Join method will return a string of ProductId’s seperated by comma like "1,2,6,7"

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

Sidebar

Related Questions

SAMPLE CODE: Dim sql As String = SELECT * FROM + tblName + WHERE
I have this sql string: Dim sqlQuery As String = SELECT TOP 1 ID,
Dim MyQuery = From c In xdoc.Descendants() _ Where c.Attribute(OriginY) IsNot Nothing _ Order
what is wrong with my code? Dim x As Integer Dim sql As String
Using the following DataTable: Dim d As New DataTable() d.Columns.Add(Product, GetType(System.String)) d.Columns.Add(Value, GetType(System.Double)) d.Rows.Add(New
In my application I use string.Format() for the SQL like this Dim strSQL As
Dim sort_slots_sql As String sort_slots_sql = _ select date, part, service, slot & _
I am running a simple select query thusly: Private Function ReturnTableQuery(ByVal SQL As String)
I have an error in the following sql. (SELECT shorthand, display, larry_ranking, site_url FROM
Dim objMail As New Mail.MailMessage(no-reply@mywebsite.com, ToEmail, Password Reset, body) ...and the problem is that

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.