cancel
Showing results for 
Search instead for 
Did you mean: 

Error setting ReportDocument.SetDataSource with Dataset

mbossu
Explorer
0 Kudos

I'm using Visual Basic 2015 (Visual Studio 2015 Professional) and SAP Crystal Report for Visual Studio SP16.

To send dynamically data from ADODB.Recordset to Report I'm setting ReportDocument.SetDataSource property with a Dataset, the same of the Report DataSource (generated with Dataset.WriteXML):

This solution work correctly in VS2008.

The cryRpt.SetDataSource  setting generate the following Error: Unable to load the database information


Attached Report DataSource Image and XML Dataset.

Thanks for help.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

No reason to call the .refresh, that refreshes the report with the original data source which would cause the database connection error.

If I create a new report off the attached xml fiile it works fiine. Could be your original report does not match the xml file.

Don

mbossu
Explorer
0 Kudos

Program execution stops before .refresh .

The error is generated from cryRpt.SetDataSource(myDS.Tables(0))

The report Data XML is generated with MyDS.writeXml(). I create a new report with this XML.

This solution works correctly in VS2008 and Crystal Report 2008..

Thanks for reply

0 Kudos

Can you attach the report so I can refresh it using you xml as a data source?

0 Kudos

It's C# but this works for me:

System.Data.DataSet ds = new System.Data.DataSet();

ds.ReadXml(@"D:\Atest\Bossu\Reti1.xml");

// as long as the field names match exactly Cr has no problems setting report to a DS.

try

{

    rpt.SetDataSource(ds.Tables[0]);

     // either one of  these work, if only 1 table in report next line will work also.

    //rpt.SetDataSource(ds);

}

catch (Exception ex)

{

    MessageBox.Show("ERROR: Schema Mismatch. Error reported by CR: " + ex.Message);

}

As long as the table name is the same it should not have a problem.

If you have multiple tables then it could be a problem, you would need to set the AliasName also.

Also used the Logon Method and that too works....

I would check your report for errors, bad formula that could be using a field that no longer exists is a known problem.

Don

mbossu
Explorer
0 Kudos

I cannot attach RPT file type..

I try to share it to following link:

https://drive.google.com/folderview?id=0ByGrZWB8_pe5ZEJIcnAySVJ6RW8&usp=sharing

mbossu
Explorer
0 Kudos

Your solution doesn't work for me..

ds.ReadXml("xxxxx\Reti1.xml")

rpt.SetDataSource(ds)

return the same error..

The solution works correctly only if Report.DataSource is connected to Database (ODBC) and not changed from application.

But I need to send data dynamically.. the use of XML I think is a correct solution.

In previous solution (VB6 and VB2008) I used TTX DataSource sending Recordset from VB application: rpt.SetDataSource(Recordset).. the solution worked correctly.

Thanks for reply

0 Kudos

Thank you for the report....

My code works for your report also.... wanted to make sure you were not using the legacy XML driver.

Only thing I can think of as to the cause is something is broken on your PC.

Check your references and make sure they are all version 13.x.x.x. sometimes VS doesn't update them all. Check your app.config file and make sure you have this in it:

<startup useLegacyV2RuntimeActivationPolicy="true">

Don

mbossu
Explorer
0 Kudos

Thanks for the support..

In google.drive I also shared the app.config file.. In the file is not present the specified setting .  Why ?


I inserted the line and the program display the report.

Thank you very much!!

0 Kudos

Something we had to do to make the ADO driver work properly for compatibility mode.

Don

Answers (0)