0

OK... After many many days of trying to figure it out, I have no option but to ask for help. I have Googled my little heart out and now it has led me here. PLEASE HELP.

I get a string from my MySQL database server. I then split the string and put it into an array.

Than I go through my checklistbox and see if any of the entries in there are equal to an array value. The problem is, it doesn't work and for the life of me I can't get it to work.

This is somewhat of a template I have and if anyone can help me out with this problem, I would be more than thankful.

    Using connection As New MySqlConnection("datasource = " + IPADDRESS + "; username = '" + USERNAME + "'; password='" + PASSWORD + "' ; database = '" + DBASE + "'")
        Using Command As New MySqlCommand("SELECT * FROM hazinc WHERE title = '" + ListBox1.Text + "'", connection)

            connection.Open()

            'Command.ExecuteReader()
            Using reader As MySqlDataReader = Command.ExecuteReader()
                While reader.Read()
                    'TextBox2.Text = reader("title")
                    STRINGRR = reader("involved")

                End While

                Dim NEWSTRINGRR As String() = STRINGRR.Split(",")

                Dim CC As Integer

                CC = 0

                For Each X In NEWSTRINGRR
                    For I = 0 To clbEmployees.Items.Count - 1
                        Try
                            If clbEmployees.Items(I).ToString() = NEWSTRINGRR(I).ToString() Then
                                SetItemChecked(I)
                            End If
                        Catch ex As Exception
                            ' MsgBox(ex.ToString)
                        End Try

                    Next
                Next



            End Using

            connection.Close()

        End Using
    End Using

Anyone? Please...?

1
  • Please post the contents of STRINGRR and the contents of the first 3 items in the clbEmployees Commented Aug 1, 2012 at 2:06

2 Answers 2

2

I don't know for sure with so little code, but why are you using the same index for your If condition? Then what good does X does?

I think it should be like :

For Each X In NEWSTRINGRR
    For I = 0 To clbEmployees.Items.Count - 1
        If clbEmployees.Items(I).ToString() = X.ToString() Then
           SetItemChecked(I)
        End If
    Next
Next

CMIIW.

Sign up to request clarification or add additional context in comments.

Comments

0

You do know STRINGRR is only going to have the value of the last row. Add yes you need to post all your code.

2 Comments

STRINGRR contains "Your Name, My Name, Her Name," - NEWSTRINGRR contains this string broken down into an array
Did you debug those values? Where values failed to match that you thought should match?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.