Solved

collection in vb.net

Posted on 2011-03-11
3
308 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
  • 2
3 Comments
 
LVL 17

Expert Comment

by:nepaluz
Comment Utility
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
Comment Utility
actually

col.Count > 0
0
 

Author Closing Comment

by:vbnetcoder
Comment Utility
yu
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now