Link to home
Start Free TrialLog in
Avatar of crafuse
crafuseFlag for Canada

asked on

Populate CheckedListBox with results of query

Experts,

I perform a query that can return more than one row. It will look like this:

select fname, lname, city, job, letter, letterdate, letterbody from tblletter where name = 'joe' and letter like '%office%';

When this query returns more than one row i would like to pop up a small form for the user with a single checkedlistboxcontrol, and iterate through the records and populate that checkedlistbox with all of the letter, letterdate, letterbody values (that is, one row in the list box that includes all three values per record). Also, if only one row is returned from the query, then forget the whole exercise...

Also, can someone please tell me what the property is for the SqlDataReader that returns a row count?

partial code'''''
        Dim conReader2 As New SqlConnection(strConnect)
        Dim conString2 As New SqlCommand(FileSQL2, conReader2)
        conReader2.Open()

        Dim drReader2 As SqlDataReader
        drReader2 = conString2.ExecuteReader(CommandBehavior.CloseConnection)
        drReader2.Read()

TIA,
crafuse
SOLUTION
Avatar of rionroc
rionroc
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crafuse

ASKER

Sorry, but I guess I wasn't very clear...

within the following code snippet (that is, where x > 1), I need to open a new form (form2) with a checked list box (lst1) and load the values into that checked list box. So...where I have put in my comment line, I need this even to happen...


If x > 1 Then

            FileSQL3 = "Select qdocall.doctyp, qdocall.datdue, qdocall.actdes from " & _
            "(qclient inner join qmatter on qclient.clinum = qmatter.clinum) left outer join qdocall on qmatter.clinum = qdocall.clinum and qmatter.matnum = qdocall.matnum " & _
            "where qclient.clinum = " & Me.txtFileNo.Text & " and qmatter.matnum = '" & Me.txtMatterNum.Text & "' and qdocall.doctyp like '%office letter%';"

            Dim conReader3 As New SqlConnection(strConnect)
            Dim conString3 As New SqlCommand(FileSQL3, conReader3)
            conReader3.Open()

            Dim drReader3 As SqlDataReader
            drReader3 = conString3.ExecuteReader(CommandBehavior.CloseConnection)
            drReader3.Read()

            'put in code to launch little form with checkedlistbox and populate that listbox with returned items.
            'after user selects one of the items in the list, throw that value back here

        End If
Hello

Can you just attach the file in zip format and I can assure to help you debug it.
It's hard to know the things that you can't completely see.


Great is our GOD.
:)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello

Thanks for the assisted points.

Now I know what you really mean with that code you show.


Great is our GOD.
:)