Crystal Reports

  • Thread starter Shawn H. Mesiatowsky
  • Start date
S

Shawn H. Mesiatowsky

I have come across lots of information regarding this, but nothing seems to
work. I have created a Crystal Report that access's a SQL server backend for
the data, and I want to display the report via a webform and the
CrystalViewer Web Component. First of all, I have been using Trusted
Connections so far (for data access) and really do not want to have some
static login information in my web app. but most of the documents so far
have indicated this has to be the case (for use with a SQL Server Backend).

http://support.microsoft.com/default.aspx?scid=kb;en;319264&sd=msdn

even with that information from Microsoft, I still cannot get the stupid
thing to work. still get the error Exception Details:
CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed

If I setup my crystal report to access certain info from a table called
mytable, can I use the same SQL String in a dataset and bind the dataset to
the report. Would this work? or is binding a dataset to a report for
dynamically creating a report (I would like to format the report visually).
Can anyone point me in the right direction here. Thank you
 
E

Elton Wang

Hi Shawn,

In my experience, a CR report in .NET doesn't have to have
log on info for get data from database. You can fill the
datatable first then use datatable as CR report's data
source, e.g.

crReport.Database.Tables(0).SetDataSource(datatable);

But some people reported that this approach has poor
performance when loading large amount data.


HTH

Elton Wang
(e-mail address removed)
 
S

Shawn H. Mesiatowsky

No Luck. I coded to open a dataset, I got the info from the database without
problems, and set the datasource for the report to my dataset. It didn't
work until I supplied Logon info again.

This didn't work:
ReportDocument crReportDocument = new ReportDocument();
string strPath;

strPath = Server.MapPath("Reports\\CrystalReport1.rpt");
string select = "SELECT * FROM Security";
SqlConnection conPubs = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conPubs.Open();
SqlCommand cmd = new SqlCommand(select,conPubs);
SqlDataReader dtrUsers = cmd.ExecuteReader();

strPath = Server.MapPath("Reports\\CrystalReport1.rpt");
crReportDocument.Load(strPath);
crReportDocument.SetDataSource(dtrUsers);

BUT THIS WORKED:

ReportDocument crReportDocument = new ReportDocument();
string strPath;

strPath = Server.MapPath("Reports\\CrystalReport1.rpt");
string select = "SELECT * FROM Security";
SqlConnection conPubs = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conPubs.Open();
SqlCommand cmd = new SqlCommand(select,conPubs);
SqlDataReader dtrUsers = cmd.ExecuteReader();

strPath = Server.MapPath("Reports\\CrystalReport1.rpt");
crReportDocument.Load(strPath);
crReportDocument.SetDataSource(dtrUsers);

crConnectionInfo.ServerName = "Roma";
crConnectionInfo.DatabaseName = "ProjectManagement";
crConnectionInfo.
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "Pioneer#cake";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

It seems to only work when supplied with a username and password. Like I
said before, I have found many docs saying you cannot use trusted
connections with Microsoft SQL Server. I am just looking for code to
actually accomplish this. I have gotten code to work no problem with MS
Access, etc.. Thanks for your help
 
E

Elton Wang

That's true. Logon info definitely works. And I think if
you already provide logon info, it's not necessary to use
datareader any more.

Sometimes dataset works, but mostly it only works by using
individual datatables.

Elton Wang

-----Original Message-----
No Luck. I coded to open a dataset, I got the info from the database without
problems, and set the datasource for the report to my dataset. It didn't
work until I supplied Logon info again.

This didn't work:
ReportDocument crReportDocument = new ReportDocument();
string strPath;

strPath = Server.MapPath ("Reports\\CrystalReport1.rpt");
string select = "SELECT * FROM Security";
SqlConnection conPubs = new
SqlConnection(ConfigurationSettings.AppSettings ["ConnectionString"]);
conPubs.Open();
SqlCommand cmd = new SqlCommand(select,conPubs);
SqlDataReader dtrUsers = cmd.ExecuteReader();

strPath = Server.MapPath ("Reports\\CrystalReport1.rpt");
crReportDocument.Load(strPath);
crReportDocument.SetDataSource(dtrUsers);

BUT THIS WORKED:

ReportDocument crReportDocument = new ReportDocument();
string strPath;

strPath = Server.MapPath ("Reports\\CrystalReport1.rpt");
string select = "SELECT * FROM Security";
SqlConnection conPubs = new
SqlConnection(ConfigurationSettings.AppSettings ["ConnectionString"]);
conPubs.Open();
SqlCommand cmd = new SqlCommand(select,conPubs);
SqlDataReader dtrUsers = cmd.ExecuteReader();

strPath = Server.MapPath ("Reports\\CrystalReport1.rpt");
crReportDocument.Load(strPath);
crReportDocument.SetDataSource(dtrUsers);

crConnectionInfo.ServerName = "Roma";
crConnectionInfo.DatabaseName = "ProjectManagement";
crConnectionInfo.
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "Pioneer#cake";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

It seems to only work when supplied with a username and password. Like I
said before, I have found many docs saying you cannot use trusted
connections with Microsoft SQL Server. I am just looking for code to
actually accomplish this. I have gotten code to work no problem with MS
Access, etc.. Thanks for your help

Hi Shawn,

In my experience, a CR report in .NET doesn't have to have
log on info for get data from database. You can fill the
datatable first then use datatable as CR report's data
source, e.g.

crReport.Database.Tables(0).SetDataSource(datatable);

But some people reported that this approach has poor
performance when loading large amount data.


HTH

Elton Wang
(e-mail address removed)
SQL
server backend for cannot
get the stupid a
report for the
report visually).


.
 

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