Solved

Dataset in Datagrid used as Datasource for Crystal Reports

Posted on 2009-05-04
5
922 Views
Last Modified: 2013-11-08
I have a Dataset being filled by code and filling a Datagrid which the user can remove items from the list.  Now I want to take the new Dataset to run a Crystal Report.  Now it works with a fresh dataset set but once I remove one row and click the refresh button on the report it errors out on me.

To test to dataset edits I have a 2nd datagrid that looks at the dataset and refreshes when item is removed from main datagrid.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        oConn.sCommand = "SELECT v_8130.ship_station, v_8130.CUSTNUM, v_8130.CITY, v_8130.SALESORD, v_8130.ENP_NO, v_8130.carton_no, v_8130.ship_to_country, v_8130.ship_to_name, v_8130.ship_to_addr_1, v_8130.ship_to_addr_4, v_8130.ship_gate, v_8130.WEIGHT FROM [501].dbo.v_8130 v_8130 WHERE (v_8130.ship_station = 0) AND v_8130.CUSTNUM = 85101 GROUP BY v_8130.CUSTNUM, v_8130.SALESORD, v_8130.CITY, v_8130.ENP_NO, v_8130.carton_no, v_8130.ship_to_country, v_8130.ship_to_name, v_8130.ship_to_addr_1, v_8130.ship_to_addr_4, v_8130.ship_gate, v_8130.ship_station, v_8130.WEIGHT"
        dset1 = oConn.executeQueryReturnDS()
        dtable1 = dset1.Tables(0)
        dtable1.TableName = "fill"
        DataGrid1.DataSource = dtable1
        DataGrid1.Refresh()
        oConn.close()
 
    End Sub
 
    Private Sub DataGrid1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGrid1.CellClick
        If DataGrid1.CurrentCell.ColumnIndex = 0 Then
            DataGrid1.Rows.Remove(DataGrid1.CurrentRow)
        End If
 
    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        DataGrid2.DataSource = dtable1
        DataGrid2.Refresh()
    End Sub
 
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim cr As Report1 = New Report1
        dtable = dtable1
        cr.SetDataSource(dtable)
        CrystalReportViewer1.ReportSource = cr
        CrystalReportViewer1.Refresh()
 
    End Sub

Open in new window

0
Comment
Question by:kwitcom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 24300192
THe report is actually working on a copy and probably doesn't get the deletes.

Since you are assigning the dataset why do you need the refresh?

mlmcc
0
 

Author Comment

by:kwitcom
ID: 24300385
The dataset is not set to the report until the report button is pressed.  If I press it at the start without deleting any rows it works fine.  When I delete from the dataset then click the button to create the report it gets errors.  Now I created a 2nd datagrid to confirm the dataset is working correctly when i do the deletes.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24300513
You may need to refresh the dataset before assigning it to the report.

You might check this link.  The dataset is built in code then attached to the report
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

mlmcc
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 24301038
have you tried to call AcceptChanges on your Dataset/Datatable before calling SetDataSource?
0
 

Author Comment

by:kwitcom
ID: 24303927
The AcceptChanges worked.  Thanks for all your help.
0

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question