Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dataset in Datagrid used as Datasource for Crystal Reports

Posted on 2009-05-04
5
Medium Priority
?
924 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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

660 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