Crystal Report Error with datasource of linq-to-sql classes

T

Trolane

I have a crystal report that i added datasources to that are classes made
from linq-to-sql designer.
This report errors trying to find logon info when i tell it export data or
use it in a viewer. There is no logon info so whats up?
I am settings the SetDataSource method with the object returned from the
LINQ query. Here's the code. The report simply has the .net object classes i
selected from the available data sources.


ABBDBDataContext db = new ABBDBDataContext();
IEnumerable<Order> o = from t in db.Orders
where t.ID == orderid
select t;

if (o == null)
return;

ABB.Reports.Invoice inv = new ABB.Reports.Invoice();

inv.SetDataSource(o);

inv.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
"c:\test.pdf");
 
J

Jon Skeet [C# MVP]

Trolane said:
I have a crystal report that i added datasources to that are classes made
from linq-to-sql designer.
This report errors trying to find logon info when i tell it export data or
use it in a viewer. There is no logon info so whats up?
I am settings the SetDataSource method with the object returned from the
LINQ query. Here's the code. The report simply has the .net object classes i
selected from the available data sources.


ABBDBDataContext db = new ABBDBDataContext();
IEnumerable<Order> o = from t in db.Orders
where t.ID == orderid
select t;

if (o == null)
return;

ABB.Reports.Invoice inv = new ABB.Reports.Invoice();

inv.SetDataSource(o);

inv.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
"c:\test.pdf");

If you run the query outside Crystal Reports, does it work? Have you
included the connection string in your .config file?
 
T

Trolane

hi, ya it has nothing to do with my linq setup.
its crystal reports saying it expects a database connection for each .net
object i added as a datasource.
 
J

Jon Skeet [C# MVP]

Trolane said:
hi, ya it has nothing to do with my linq setup.
its crystal reports saying it expects a database connection for each .net
object i added as a datasource.

That sounds very odd indeed. Could you post the exact error message,
including a stack trace if you've got one?
 
T

Trolane

CrystalDecisions.CrystalReports.Engine.LogOnException was unhandled by user
code
Message="Logon failed.\nDetails: crdb_adoplus : Object reference not set
to an instance of an object.\rError in File
C:\\Users\\Aaron\\AppData\\Local\\Temp\\temp_282d1676-8da7-4872-9948-0a1128f99059
{616FB1AC-0B3C-4F6B-ABE0-8AD7FD2725E4}.rpt:\nUnable to connect: incorrect log
on parameters."
Source="CrystalDecisions.ReportAppServer.DataSetConversion"
StackTrace:
at
CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at
CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at
CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at
CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName)
at ABB.Invoice.Page_Load(Object sender, EventArgs e) in
C:\Users\Aaron\Documents\Visual Studio
2008\Projects\ABB\ABB\Invoice.aspx.cs:line 40
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,
Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.Runtime.InteropServices.COMException
Message="Logon failed.\nDetails: crdb_adoplus : Object reference not
set to an instance of an object.\rError in File
C:\\Users\\Aaron\\AppData\\Local\\Temp\\temp_282d1676-8da7-4872-9948-0a1128f99059
{616FB1AC-0B3C-4F6B-ABE0-8AD7FD2725E4}.rpt:\nUnable to connect: incorrect log
on parameters."
Source=""
ErrorCode=-2147217393
StackTrace:
at
CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at
CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
InnerException:
 
J

Jon Skeet [C# MVP]

Trolane said:
CrystalDecisions.CrystalReports.Engine.LogOnException was unhandled by user
code
Message="Logon failed.\nDetails: crdb_adoplus : Object reference not set
to an instance of an object.\rError in File
C:\\Users\\Aaron\\AppData\\Local\\Temp\\temp_282d1676-8da7-4872-9948-0a1128f99059
{616FB1AC-0B3C-4F6B-ABE0-8AD7FD2725E4}.rpt:\nUnable to connect: incorrect log
on parameters."

Okay, that's not saying it's failing to *find* the log on parameters -
they're just incorrect.

Is it possible that this is due to the account that ASP.NET is running
under? Can you see the data from other pages in the same web app?
 
T

Trolane

there are no logon parameters. crystal isnt talking to sql server. the linq
is and the linq is reading from the web.config for the connection string.
the linq woirks all over the site and its in the debugger so there is no
permission issues because it runs as admin.
 
J

Jon Skeet [C# MVP]

Trolane said:
I have a crystal report that i added datasources to that are classes made
from linq-to-sql designer.
This report errors trying to find logon info when i tell it export data or
use it in a viewer. There is no logon info so whats up?
I am settings the SetDataSource method with the object returned from the
LINQ query. Here's the code. The report simply has the .net object classes i
selected from the available data sources.


ABBDBDataContext db = new ABBDBDataContext();
IEnumerable<Order> o = from t in db.Orders
where t.ID == orderid
select t;

if (o == null)
return;

ABB.Reports.Invoice inv = new ABB.Reports.Invoice();

inv.SetDataSource(o);

inv.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
"c:\test.pdf");

No sub-reports that need extra data? I'm grasping at straws here, to be
honest, based on Google searches you've probably done yourself...
 
S

Sachin poddar

Hi, I am having the similar problem. I am using visual studio 2008
having Project's .net objects as data source When I assign the .net
objects as new data source at run time report prompts me to enter
database login & password which fails to login.
 
T

Trolane

i never found a solution for it. Ended up making a dataset and loading that
with the data from the LINQ. such a waste of resources to do it though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top