Question odd DataSet AddNew / Create Crystal Report issue

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
I've set my app up so that when I run a crystal report, I connect to the same DataSet that my data has loaded from into the form, and just pass over the parameter of the ID needed for the report.

If I fill the dataTables blah blah blah, the report will load fine.

When I create a new record from my "new record" Form, and press the report button, the report comes back blank.
Now, I assume this is because I haven't actually "filled" the data, however, surely after supplying the information and updating it to the dataTable to add a new record, this then exists (albeit by itself) in that dataTable.

Not sure why the report is blank. If I then use my search form to search for that record, I can load the report no problems.

Both forms use the same report, and EXACTLY the same code to open that report.

Any ideas?
 
Your complaint seems to be:

"When I provide a crystal report with a datatable containing some RowState.Unchanged rows, the report shows the correct data. When I provide a crystal report with a datatable containing one RowState.Added row, the report shows nothing"

At the point, my surmisation would be that you should AcecptChanges before giving the table to crystal
 
I'm starting to become confused:

"updating it to the dataTable to add a new record"
"I run TableAdapter.Update"

I thought you knew tableadapters are for dt <-> rdbms pushing, not for dt only?

You need to explain this a little more clearly. Start by telling us what you do that works and what does not. Are you sure that your crystal is using the DT for its dataource? The only other thing I can infer from your post is that when daata exists in a database, the report works but when it exists only in a DT then it is blank == crystal is pulling the data from the DB, NOT your datatable
 
You're confused, so am I :)

Right...

"create new record" form:

On load:
.addnew

fill in all the information on screen, click submit. This calls
.update(dataset.datatable)

If I go to the database, the new record is there, so it exists. Which means it exists in the DataTable AND in the DataBase.

I then have a button which opens a crystal report.
VB.NET:
 Dim rpt As New rptReport1
        rpt.SetDataSource(Me.DsDevelopment)
        rpt.SetParameterValue("ID", Me.lblID.Text)
        Me.crViewer.ReportSource = rpt

Click that button, report comes back BLANK - headers are there, but no data.

-------

"data browse form"

on load:
.fillby queries

user can browse through records returned by the Fill query.

Click Report Button, with EXACTLY the same code as posted above, and the report data is there.


Make a little more sense?
 
Something must be different about the two.. look harder! :)
RowStates, RowVersions, data types, lengths etc. Use a FillBY to fil lthe exact same data as youre addnewing (just dont do the Update() part if your data already exists) - do they both show? Both the locally added AcceptChagnes()d and the Fill()ed versions?
WHAT is different about the two datasets? (get them on screen at the same time) Relations? Parent data?

Something..
 
Tis all the same... I've had an idea which I think is stupid but it may prove something..

after submitting a new row, I'm going to take that ID, clear the dataset, and then fill the dataTable(s) based on that ID, and try to open the report then
 
Tis all the same...

Can't be. Right now youre asserting that these two would behave differently:

Dim i as Integer = 2
Dim j as Integer = 1 + 1

If crystal only ever sees "2", how can it decide not to work when the answer was derived from 1+1? There MUST be something different about what youre doing to the data you give to crystal, or what it gets when it fetches the data (i dont know how you set it up)
 
VB.NET:
Dim rpt As New rptReport1
rpt.SetDataSource(Me.DsDevelopment)
rpt.SetParameterValue("ID", Me.lblID.Text)
Me.crViewer.ReportSource = rpt

Is the code on both forms. Me.lblID is on both forms, both with an ID.

The only difference is AddNew vs FillBy in terms of how the form runs.
 

Latest posts

Back
Top