on 02-15-2012 7:27 PM
Hi
I am having a problem with refreshing a crystalreport version 2010 used in visualstudio 2010
I created a DLL where a pass some values and in dll i create the objecto ReportDocument
I load the report and pass it a query to load new data but it shows the old data, the report is saved with Save data to report unchecked.
What's wrong, why report doesn't load new data?
there is part of my code that use
Private ReporteCR As New CrystalDecisions.CrystalReports.Engine.ReportDocument
ReporteCR.Load(PathReporte)
ReporteCR.Refresh()
odt = Serv.TraerDataTable(strsql)
' solo necesita user/pwd para evitar ventana de logon
ReporteCR.SetDatabaseLogon(sUsuario, sPwd) ' , sServidor, sBD
' ''Dim savedata As Boolean
' ''savedata = ReporteCR.ReportOptions.EnableSaveDataWithReport
ReporteCR.ReportOptions.EnableSaveDataWithReport = False
ReporteCR.ReportOptions.EnableUseDummyData = False
' '' '' '' ''ReporteCR.ReportOptions.EnableSaveSummariesWithReport = False
' ''If savedata = False And ReporteCR.HasSavedData = True Then
' '' ReporteCR.Refresh()
' '' ReporteCR.VerifyDatabase()
' ''End If
' ''ReporteCR.VerifyDatabase()
' Pasa los datos al reporte
ReporteCR.SetDataSource(odt)
' Asigna objeto crystal a reportviewer
CrystalReportViewer1.ReportSource = ReporteCR
Hello,
After you set location the do a refresh just before the viewer.
Are you hitting the Viewers Refresh button?
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code looks pretty messed up to me;
You load the report, then you refresh it then you log it on to the database, then you pass it a dataset(?) or something... E.g.;
You are logging on to the database:
ReporteCR.SetDatabaseLogon(sUsuario, sPwd) ' , sServidor, sBD
Then you are passing what appears to be an ADO .NET dataset to the report:
ReporteCR.SetDataSource(odt)
Do, one or the other. If you want to pass a dataset to the report, you do not need to logon to the database. If you want to use data from the database directly, don't pass in a dataset.
I assume that you want to do the former, thus comment out the following:
ReporteCR.SetDatabaseLogon(sUsuario, sPwd) ' , sServidor, sBD
If that causes issues, see the blog [Troubleshooting Issues with VS .NET Datasets and Crystal Reports|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13270
All I said above is predicated on the assumption that "odt" is an ADO .NET Dataset(?). That being the case, the general code flow should be:
Create dataset
Load report
Pass dataset to report
View report
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]
Hi Ludek
I'm using a datatable object to pass info to the report.
The report has a ODBC conection made in design time
if i don't use setdatabaselogon , it ask me for password for logon
in fact i wrote a dll proyect for show crystalreport, just pass some properties, a sql query string and in the dll opens the crystalreportviewer for show resuls, within dll i uses a access data dll (methods TraerDatatable/TraerDAtaset for retrieve data)
the main problem is that crystalreport doesn't show updated data and i don't know why?
Ok. Your code should be as follows:
Private ReporteCR As New CrystalDecisions.CrystalReports.Engine.ReportDocument
ReporteCR.Load(PathReporte)
odt = Serv.TraerDataTable(strsql)
ReporteCR.SetDataSource(odt)
CrystalReportViewer1.ReportSource = ReporteCR
If that results in a db logon, it's because the structure of the odt object is not what the report is expecting. E.g.; the schema is different. You can check this out by writing out the odt object into an XML file. Then open the report in the CR designer. Point the report at the xml and see what happens now. My guess is that you will get a field mapping dialog, indicating that there is something in the xml / odt object that the report does not understand.
- Ludek
It looks like you are using DataTable and setting the DataSource to use the datatable.
The datatable access the data stored in-memory cache of data retrieved from a data source.
Even if you try to refresh the the crystal report it's going the bring the same that that has been brought by Datatable/DataSet earlier.
This could be a good read:
http://msdn.microsoft.com/en-us/library/system.data.dataset(v=vs.71).aspx
- Saurabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.