collection in vb.net

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
vbnetcoderAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
nepaluzConnect With a Mentor Commented:
actually

col.Count > 0
0
 
nepaluzCommented:
try

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

Open in new window

0
 
vbnetcoderAuthor Commented:
yu
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.