Results 1 to 2 of 2

Thread: Need to use For Next Loop with Datareader

  1. #1

    Thread Starter
    Join Date
    Jun 2005

    Need to use For Next Loop with Datareader

    Could you please tell me, i want to use a For Next Loop with the datareaders data:
    for getting the values for ringtoneid, wallpaperid,sellerid from datareaders data.

    i want to use each data readers row values to perform another function.

    I can do the above function using a dataset but, i heard from many that datareaders performance is good, thats why i am trying to do with datareader.

    strConnection = ConfigurationSettings.AppSettings("QMain")
    MyConnection = New SqlConnection(strConnection)

    Dim myTopCommand As SqlCommand = New SqlCommand("select * from categoryid order by id", MyConnection)

    Dim dr As SqlDataReader = myTopCommand.ExecuteReader()

    If Not (dr Is Nothing) AndAlso dr.HasRows Then
    sRingtoneID = dr("ringtoneid").ToString
    sWallPaperID = dr("wallpaperid").ToString
    stSeller = dr("sellerid").ToString
    End If

    Thank you very much for the information.

  2. #2
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Planet Earth

    Re: Need to use For Next Loop with Datareader

    try a while loop.
    Your going to have to create a collection or array or listbox etc... to put your values or
    each record will overwrite the last as your iterating throught the recordset
    (as you have it now)

    VB Code:
    1. while
    2. '
    4. end while
    Truly, you have a dizzying intellect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width