hi I'm having problems in my crystal report where all the selected rows in my datagrid will show up in my crystal report but instead it showing me an exception selectcommand.connection has not been initialized
here's my code in my form where the datagrid is:
Dim cmd As OleDbCommand = New OleDbCommand("SELECT Data1.ID, Data1.DateFile as [Date File] , Data1.Plate as [Plate #], Data1.Driver as Driver, Data1.EmpID as EmpID, Data1.OdometerBefore As [Odometer Before], Data1.OdometerAfter As [Odometer After], Data1.Gas as Gas, Data1.CostofGas as [Cost of Gas] FROM Data1", con)
con.Open()
adpt = New OleDbDataAdapter(cmd)
'Here one CommandBuilder object is required.
'It will automatically generate DeleteCommand,UpdateCommand and InsertCommand for DataAdapter object
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(adpt)
DtSet = New DataSet()
adpt.Fill(DtSet, "Data1")
DataGridView1.DataSource = DtSet.Tables("Data1").DefaultView
DataGridView1.Columns(0).Visible = False
con.Close()
con = Nothing
here's my code in my crystal report. my crystal report will show once a button is clicked from the previous form and my connection is in public
Dim cmd As New OleDbCommand("Select * From Data1 Where DateFile = " & 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
crystal.SetDataSource(DtSet.Tables("Data1"))
CrystalReportViewer1.ReportSource = crystal
CrystalReportViewer1.Refresh()