|
Subject:
|
"Invalid object format name" Error
|
|
Posted By:
|
welles
|
Post Date:
|
2/15/2006 3:38:54 PM
|
Hi there,
I am trying to upgrade a crystal application from VS.Net 2003 to VS.Net 2005. Some of the reports work just fine in the new enviroment. But one of the reports does give me a hard time.
It is a little complicated, so please bare with me. The report uses a c# derived DataSet class as its Database Fields source. It also uses a DataTable as its data source. When I try to bind the report with the data source, for example, myReport.setDataSource(myDataTable);. It throws the following exception:
CrystalDecisions.CrystalReports.Engine.InternalException was unhandled by user code Message="\rError in File C:\\WINDOWS\\TEMP\\temp_c2eb4661-c3c0-429a-9d9f-c0b280e112bc {645E2563-B9C6-4A6F-9714-618DF7CB1EE2}.rpt:\nInvalid object format name." Source="CrystalDecisions.ReportAppServer.DataSetConversion" StackTrace: at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataTable dataTable) at NL2.Web.GlRptFsWModule.getReport(Boolean sendToPrinter, exportTo eExport) in c:\Inetpub\wwwroot\NL2\Web\reports\GlRptFsWModule.ascx.cs:line 900 at NL2.Web.GlRptFsWModule.cViewButton_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\NL2\Web\reports\GlRptFsWModule.ascx.cs:line 1246 at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I traced the program and realized that once I change the format of the FieldObject and call the report object's refresh() method, the same exception is thrown. For example:
myReport.Refresh(); // ok here myFiledObject.Width = 0; myReport.Refresh(); // throw exception
I also tried to reset all the FieldFormat for the FieldObject, but the same thing happen. Once I change the FieldFormat and refresh, it throws an exception. I am so confused now!
myReport.Refresh(); // ok here myFiledObject.FieldFormat.BooleanFormat.OutputType = BooleanOutputType.TrueOrFalse; myReport.Refresh(); // throw exception
Can any crystal report expert/genius give me some hints on what did I do wrong or what could be the problem? Thanks in Advance!
|
|
Reply By:
|
WebMasterSam
|
Reply Date:
|
9/20/2006 3:04:36 PM
|
Hi,
When you write a Strongly-Typed DataSet in .Net, the default format is String. When you bind your DataSet to the Crystal Report, it also binds it's format... so when you programmatically pass your dataset to your report by using SetDataSource(), be sure that all your fields in your dataset returned from the database are in the string format (by explicitly using CAST ( [NumericField] AS VARCHAR(precision) ) in your stored procedure. If you need to keep the numeric format (datetime, or anything else...).
This is why it says "Invalid object format name." 
WebMasterSam 
|
|
Reply By:
|
Princess
|
Reply Date:
|
9/27/2006 4:42:58 AM
|
you will not believe it, but it worked with me. no matter your strongly-typed dataset fields' data types. use empty formulas in your crystal report. at runtime adjust the format for any fieldobject, at the end set the formula("formula-name").text = "formula expression" you can do this for each formula and all formulas in concern then at the end bind your report to your data source as you do now. and then every thing will work. the whole idea is to change the order of your statments, set the formula expression the last thing after changing all its other properties. pls let me know if it worked with you.
Princess
|