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.Tab le 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
"Elton Wang" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
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(datatabl e);
But some people reported that this approach has poor
performance when loading large amount data.
HTH
Elton Wang
el********@hotmail.com
-----Original Message-----
I have come across lots of information regarding this,
but nothing seems towork. I have created a Crystal Report that access's a SQL
server backend forthe data, and I want to display the report via a webform
and theCrystalViewer Web Component. First of all, I have been
using TrustedConnections so far (for data access) and really do not
want to have somestatic login information in my web app. but most of the
documents so farhave 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 stupidthing to work. still get the error Exception Details:
CrystalDecisions.CrystalReports.Engine.LogOnExce ption:
Logon failed
If I setup my crystal report to access certain info from
a table calledmytable, can I use the same SQL String in a dataset and
bind the dataset tothe report. Would this work? or is binding a dataset to a
report fordynamically creating a report (I would like to format the
report visually).Can anyone point me in the right direction here. Thank
you
.