Solved

Dataset in Datagrid used as Datasource for Crystal Reports

Posted on 2009-05-04
5
920 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 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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:…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 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