I can post a single line of row I selected from datagridview but I want to select specific multiple rows then display it in my crystal report. BTW I'm using VB2010.

Dim cmd As New OleDbCommand("Select * From Data1 Where ID = " & Form4.DataGridView1.SelectedRows(0).Cells(0).Value.ToString() & "", Form4.con)

        Dim adpt As New OleDbDataAdapter(cmd)
        Dim DtSet As New DataSet
        Form4.con.Open()
        adpt.Fill(DtSet, "Data1")


        Dim crystal As New CrystalReport1

        crystal.SetDataSource(DtSet.Tables("Data1"))
        CrystalReportViewer1.ReportSource = crystal
        CrystalReportViewer1.Refresh()
        Form4.con.Close()

nevermind............problem solved

commented: How you solved it? +0

Same pblm I have,how can you solved ur pblm.pls help.

I have small issue with my datagridview and crystal report

I am using this code for display my crystal report but my problem is I can display only one row from data grid view

But I want to print all rows randomly selected from datagridview in crystal report

Private Function MontoringInfo () As IMS

        Try

            Dim objConn As SqlConnection = New SqlConnection(strConn)

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

            For Each row As DataGridViewRow In dataGridView1.Rows
                For i As Integer = 0 To dataGridView1.Rows.Count - 124

                    objComm.CommandText = "SELECT * FROM table1 where Upazila = '" & dataGridView1.SelectedRows(i).Cells(2).Value.ToString() & "'"
                Next

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


            da.Fill(ds, " table1 ")


            Return ds

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

    Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrr.Click
        Dim cry As ReportClass = New Data_main
        cry.SetDataSource(MontoringInfo ())
        Dim rc As New Reportviewer(cry)
        rc.ShowDialog()

Here Is My Process Of Application

I have clicked on load button and it loads all data from database to datagridview

After that when i click on particular row its display only one row in crystal report but i want to display all current rows which was in datagriwview

Here What's Happen

First I have Clicked ON Row in datagridview

It shows in crystal report one row but i want to print all rows current rows

Please Help what should i do print all current rows thank you

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.