hi
im using vb.net2005
&
i want to generate a crystal report dynamically as the data shown from the data gridview i.e.,
i have added checkboxes to 1st datagridview & if i check those checkboxes
the respective data values can be shown in 2nd datagridview
now i need to print those values in crystal report dynamically
can i use the same dataset to generate report which i have used to show the selected values in 2nd datagridview
plz help me out its urgent
&
the code is
Imports System.Data.SqlClient
Public Class prftblty_cols
Dim con As New SqlConnection
Dim cmd, cmd1, cmd2 As New SqlCommand
Dim adpt, adpt1 As New SqlDataAdapter
Dim dr, dr1 As SqlDataReader
Dim ds As DataSet
Dim row As DataRow
Dim dt, dt1 As DataTable
Dim ctr As String
Private Sub prftblty_cols_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
con.ConnectionString = "Server= harika;uid=sa; initial catalog=superlynx"
con.Open()
cmd.CommandText = "select * from prftblty_Cols"
cmd.Connection = con
cmd.CommandType = CommandType.Text
adpt = New SqlDataAdapter(cmd.CommandText, con)
ds = New DataSet
adpt.Fill(ds, "reports")
dt = New DataTable
dt = ds.Tables("reports")
DataGridView1.DataSource = dt
Catch ex As Exception
MsgBox("Load" & ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim i, j As New Integer
Dim arr As New ArrayList
Dim Ds1 As New DataSet
Dim array As New ArrayList
Dim str As String = ""
Dim k As Integer
For i = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows(i).Cells(0).Value = True Then
array.Add(DataGridView1.Rows(i).Cells(1).Value)
End If
Next
str = str & "select "
For k = 0 To array.Count - 1
str = str & array(k)
If k < array.Count - 1 Then
str = str & ","
End If
Next
str = str & " from vwprftblty"
cmd1.CommandText = str.ToString
Dim sqld As New SqlDataAdapter(str.ToString, con)
sqld.Fill(Ds1, "comm")
DataGridView2.DataSource = Ds1.Tables("comm")
End Sub
End Class
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).