Solved

Dataset in Datagrid used as Datasource for Crystal Reports

Posted on 2009-05-04
5
914 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
  • 2
  • 2
5 Comments
 
LVL 100

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 100

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 69

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now