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