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
        adpt.Fill(DtSet, "Data1")

        Dim crystal As New CrystalReport1

        CrystalReportViewer1.ReportSource = crystal
3 Years
Discussion Span
Last Post by waterm

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

Edited by waterm


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


            Dim objConn As SqlConnection = New SqlConnection(strConn)

            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() & "'"

            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)

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.