In my database one user can have multiple order. i want to get all orders for a user and save it in a list.
this is what i’m doing now
Public Function GetUserOrders(ByVal userID As Integer) As DataSet
Dim sqlDA As New SqlDataAdapter
Dim ds As New DataSet
Dim myCommand As New Data.SqlClient.SqlCommand("sp_GetUserOrders", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
Dim muserID As New SqlParameter("@userID", SqlDbType.Int)
muserID.Value = userID
myCommand.Parameters.Add(muserID)
Try
' Open the connection and execute the Command
myConnection.Open()
sqlDA.SelectCommand = myCommand
sqlDA.Fill(ds)
Catch ex As Exception
Finally
myConnection.Close()
End Try
Return ds
End Function
but i can’t seem to figure out how to assign the results to a list.
Dim orderList As New ListItemCollection()
orderlist = GetUserOrders()
does not work, please help.
i got it.
i set the list inside the getuserorders function.