Solved

collection in vb.net

Posted on 2011-03-11
3
341 Views
Last Modified: 2012-05-11
I am doing this and it errors on this line. ss = col.Item(0).ToString why? is there a better way to do this?

 
This is the code

   Dim col As New Collection

        Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand("spReturnCategoryIDByProductID ", Connection)
        'Add the parameters for the SelectCommand.
        Dim dr As SqlClient.SqlDataReader

        With command
            .Parameters.Add("@Product_ID", SqlDbType.Int)
            .Parameters("@Product_ID").Value = ProductID
            .CommandType = CommandType.StoredProcedure
            dr = .ExecuteReader
        End With


        Do While dr.Read
            col.Add(dr("Category_ID"))
        Loop

        Dim i As Integer
        For i = 1 To col.Count
            Dim ss As String
            ss = col.Item(0).ToString

        Next
0
Comment
Question by:vbnetcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 35113095
try

If col.Count > 1 Then
For i = 1 To col.Count
  col.item(i).tostring
Next
End If

Open in new window

0
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 35113099
actually

col.Count > 0
0
 

Author Closing Comment

by:vbnetcoder
ID: 35113144
yu
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question