missjace 0 Newbie Poster

Hi! Can anyone suggest to me the appropriate code for me to be able to generate the info I needed?

I'm having a problem in producing a certain number of record in a field for one primary key.

I'm doing a profiling system intended for a police department.

I have 2 queries.
My fields in my in my first query are: Prisoner'sID, LastName, FirstName, MiddleName, NoOfCases
In my second query I have: CaseNumber, NatureOfOffense, CaseFiled, LastName, FirstName, MiddleName, ArrestingOfficer and Status.

What I wanted to happen is for every search by name, the NoOfCases recorded in that person's Prisoner'sID will be shown.

For example: I have been convicted 5 times and friend has a cases filed 3 times.

I wanted to my database to show in my listview that I have 5 cases that has been recorded in my ID and 3 in my friend's ID.

Here is my code in my current program:

Private Sub txtSearchPrison_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearchPrison.TextChanged
        
str = ("Count CaseFiled as NoOfCases from Prison1 where PN = '"& txtSearchPrison &"'")
SetRS()

RS.Close()
Dim row As Integer = 0
        str = ("select * from Prison1 where PN like '%" & txtSearchPrison.Text _
                       & "%' or LastName like '%" & txtSearchPrison.Text _
                       & "%' or FirstName like '%" & txtSearchPrison.Text _
                       & "%' or MiddleName like '%" & txtSearchPrison.Text _
                       & "%' or Alias like '%" & txtSearchPrison.Text _
                       & "%' or GangName like '%" & txtSearchPrison.Text _
                       & "%' or CN like '%" & txtSearchPrison.Text _
                       & "%' or NoOfCases like '%" & txtSearchPrison.Text & "%'")
        SetRS()

        row = 0

        While Not RS.EOF
            lstPrisoner.Items.Clear()
            lstPrisoner.Items.Add(RS.Fields(0).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(1).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(2).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(3).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(4).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(5).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(6).Value)
            lstPrisoner.Items(row).SubItems.Add(RS.Fields(7).Value)
            RS.MoveNext()
            RS.Close()
        End While

Thanks in advance for the help!