Data Access Layer - loop while

Hello folks, I've a little problem.
I've some code using sqldatareader and I want to replace everything for objectdatasource

In resume I want to know how to implement a WHILE in datasets statments. Right now my DAL code access only to one row and I want to access to all rows returned.

I want to convert this SQL CODE:

                                sql_series2 = " SELECT cantidad FROM carrito_tem WHERE (LibroSerie = '@LibroSerie') AND  IdUsuarios=@idpedido"
                                cmd2.CommandText = sql_series2
                                cmd2.Parameters.Add("@LibroSerie", SqlDbType.NVarChar, 250)
                                cmd2.Parameters("@LibroSerie").Value = promo1Collection
                                cmd2.Parameters.Add("@idPedido", SqlDbType.NVarChar, 50)
                                cmd2.Parameters("@idPedido").Value = Session("Usuario")

                                cmd2.Connection = con2
                                Dim rdr3 As SqlDataReader = cmd2.ExecuteReader()
                                While rdr3.Read()
                                    Response.Write(rdr3("cantidad").ToString)

                                End If
                                rdr3.Close()

TO SOMETHING LIKE THIS

                sql_series2 = New DataSetTableAdapterssql_series2
                Dim sql_series2_data As DataSet.sql_series2DataTable = sql_series2.GetById(IdUsuarios,LibroSerie )

                If sql_series2_data.Count > 0 Then
                    response.write(sql_series2_data(0).dEmId.ToString())
                End If

THANKS FOR ANY HELP
LVL 5
nkoriginalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Use a for loop

For i as integer = 0 to sql_series2_data.count - 1
    Response.Write(sql_series2_data.Rows(i).dEmId)
Next
0
KinjalKumar PatelSenior Software EngineerCommented:
Can you please let me know that you want to use ObjectDataSource or not?? Or you want to use DataSet and Datatables so that you can access any of the row without traversing through the DataReader. Will help me to answer you in a better way.
0
nkoriginalAuthor Commented:
Kinjal I would like to use objectdatasource.
Thanks for your hellp
0
nkoriginalAuthor Commented:
The answer to my question is
This is an example.

Dim productsAdapter As New NorthwindTableAdapters.ProductsTableAdapter()
Dim products As Northwind.ProductsDataTable = productsAdapter.GetProducts()

For Each product As Northwind.ProductsRow In products
If Not product.Discontinued AndAlso product.UnitsInStock <= 25 Then
    product.UnitPrice *= 2
End if
Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.