vbnetcoder
asked on
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("spRe turnCatego ryIDByProd uctID ", 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.StoredProcedur e
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
This is the code
Dim col As New Collection
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand("spRe
'Add the parameters for the SelectCommand.
Dim dr As SqlClient.SqlDataReader
With command
.Parameters.Add("@Product_
.Parameters("@Product_ID")
.CommandType = CommandType.StoredProcedur
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yu
Open in new window