Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to select multiple item from listbox and pass this data to crystal report.
my code likes--

VB
Private Function MontoringInfo1() As IMS

        Try

            Dim objConn As SqlConnection = New SqlConnection(strConn)

            objConn.Open()
            Dim objComm As SqlCommand = New SqlCommand()

 objComm.CommandText = "SELECT Division,District,Upazila ,Total_form,Received_form,Booth_no,Receving_date,Remarks from Table1 WHERE Upazila = '" & ListBox1. selecteditem & "'"

                
            
            objComm.Connection = objConn
            objComm.CommandType = CommandType.Text
            Dim da As SqlDataAdapter = New SqlDataAdapter(objComm)
            Dim ds As IMS = New IMS()

            da.Fill(ds, "PMT_Application")

            Return ds

        Catch ex As SqlException
            MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error")
            Return Nothing
        End Try
    End Function

Private Sub btnPrintview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintview.Click

        Dim cry As ReportClass = New Data_main
        cry.SetDataSource(MontoringInfo1())
        Dim rc As New Reportviewer(cry)
        rc.ShowDialog()
    End Sub
but the problem in this code is it select only one value from listbox,it doesn't select multiple value.selecteditems property doesn't works here .how can i able to solve this problem please help.I also try to use----
VB
For i = 0 To ListBox1.Items.Count - 1
           If ListBox1.Items(i).selected Then
End if
Next

it's not work.
Posted
Updated 12-Nov-14 18:54pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900