Checkbox list

I have a radList that uses checkboxes.

My attached code sets everything to checked EXCEPT the first item on the returned data.  It always skips the first one.
If dR.HasRows Then
            Dim j As Integer
            ' Check only those which match with database
            If dR.HasRows Then
                Do While dR.Read()
                    For j = 0 To RadListBox1.Items.Count - 1
                        If RadListBox1.Items(j).Value = dR("fips") Then
                            RadListBox1.Items(j).Checked = True
                        End If
                    Next
                Loop
            End If
        Else

Open in new window

Larry Bristersr. DeveloperAsked:
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.

13598Commented:
What is the line right before your first 'If dR.HasRows Then'  that you posted?
Are you reading the dr I suppose?
Then your Do while dr.read brings in the second record since you read once to find out if there are any rows. You skipped the first record.
0
Larry Bristersr. DeveloperAuthor Commented:
13598
The full sub is attached
Protected Sub selectLinks(ByVal id As Integer)
        Dim objConn As SqlConnection
        objConn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))
        Dim oCom As SqlCommand
        oCom = New SqlCommand
        oCom.Connection = objConn
        oCom.CommandText = "dbo.sp_parse_list"
        oCom.CommandType = CommandType.StoredProcedure
        oCom.Parameters.Add(New SqlParameter("@id", SqlDbType.Int)).Value = id
        oCom.Parameters.Add(New SqlParameter("@col", SqlDbType.VarChar, 20)).Value = "fips"
        oCom.Parameters.Add(New SqlParameter("@tbl", SqlDbType.VarChar, 20)).Value = "court_Runners"
        objConn.Open()
        Dim dR As SqlDataReader
        dR = oCom.ExecuteReader()
        dR.Read()
        If dR.HasRows Then
            Dim j As Integer
            ' Check only those which match with database
            If dR.HasRows Then
                Do While dR.Read()
                    For j = 0 To RadListBox1.Items.Count - 1
                        If RadListBox1.Items(j).Value = dR("fips") Then
                            RadListBox1.Items(j).Checked = True
                        End If
                    Next
                Loop
            End If
        Else
        End If
    End Sub

Open in new window

0
13598Commented:
REmove dr.Read()
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

13598Commented:
Protected Sub selectLinks(ByVal id As Integer)
        Dim objConn As SqlConnection
        objConn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))
        Dim oCom As SqlCommand
        oCom = New SqlCommand
        oCom.Connection = objConn
        oCom.CommandText = "dbo.sp_parse_list"
        oCom.CommandType = CommandType.StoredProcedure
        oCom.Parameters.Add(New SqlParameter("@id", SqlDbType.Int)).Value = id
        oCom.Parameters.Add(New SqlParameter("@col", SqlDbType.VarChar, 20)).Value = "fips"
        oCom.Parameters.Add(New SqlParameter("@tbl", SqlDbType.VarChar, 20)).Value = "court_Runners"
        objConn.Open()
        Dim dR As SqlDataReader
        dR = oCom.ExecuteReader()
                If dR.HasRows Then
 Dim j As Integer
            ' Check only those which match with database

                Do While dR.Read()
                    For j = 0 To RadListBox1.Items.Count - 1
                        If RadListBox1.Items(j).Value = dR("fips") Then
                            RadListBox1.Items(j).Checked = True
                        End If
                    Next
                Loop
            End If
           End Sub
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
Larry Bristersr. DeveloperAuthor Commented:
13598:
Oh man...that is REALLY embarrassing!

As soon as I copied my code into the EE and submitted I saw it.

End of day brain gas!
Thanks
0
13598Commented:
It happens   lol
0
Larry Bristersr. DeveloperAuthor Commented:
Thanks...end of day tired brain!
0
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.