we have problem regarding to the list view portion as you can see on the figure.
On the left list view, we have a list of authors which data bounded through the database.
we want it to transfer several of the information on the right list view then get its primary key from the database.
as of now we have only this piece of code.

Try
    Dim i As Integer

    For i = 0 To lvSelectedAuthor.Items.Count - 1
        mysqlconn.Open()
        sqlstr = "SELECT * FROM author " & _
            "WHERE author.authorno = " & AuthorListBox.SelectedIndex

        sqlcmd = New MySqlCommand(sqlstr, mysqlconn)
        sqldr = sqlcmd.ExecuteReader

        While sqldr.Read
            MsgBox(sqldr("authorno").ToString)
        End While


        sqldr.Close()
        mysqlconn.Close()
    Next
Catch ex As Exception
    MsgBox(ex.ToString)
End Try

we try to loop it but in return it was only retrieving the same primary key on the database which is the selected index on the left list view.
your answers is very much appreciated.
thanks in advance.

you said left list view is bounded, you should also retrieve the primary keys its like,

SELECT PrimaryKey, AuthorName FROM author

AuthorName column is bounded to leftListView.

'add the Author,
leftListView.Items.Add(AuthorName)

When user select author from the left select the corresponding PrimaryKeys of the selected author.

  Private Sub leftListView_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles leftListView.SelectedIndexChanged
         'Show the primary key by selecting the first index
         MsgBox(leftListView(0).ToString)
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.