Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project i use EF4, but the connection string of the EF Context are dynamically generated and not saved in any Configuration file, everything works fine...

When i want to use Crystal report to view my reports, I used Datasets that import data form the my Entities (linq), and than set the Datasets as Datasources to the reports Tutorial Here

But at the moment of the display (in the CrystalReportViewer) a login prompt window pops up, asking for Login & Password (also the Server name and database name but the fields are disabled)

Print Screen Here

I Googled and i noticed that most of the solutions proposed concentrate around : Setting credentials in the code (like this) :

C#
ConnectionInfo crconnectioninfo = new ConnectionInfo();
crconnectioninfo.ServerName = "localhost";
crconnectioninfo.DatabaseName = "dbclients";
crconnectioninfo.UserID = "ssssssss";
crconnectioninfo.Password = "xxxxxxx";


but here is how i create my report :

C#
for (i = 0; i < 7; i++)
{
    DataRow dr = container.NewRow();
    dr = CreateRowFromMirrorRow(dr, i); //Methode that creates a Row
    container.Rows.Add(dr);
}

objRpt.SetDataSource(container.DefaultView);

// Binding the crystalReportViewer with our report object. 
crystalReportViewer1.ReportSource = objRpt;
crystalReportViewer1.Refresh();
crystalReportViewer1.Visible = true;


My questions are :

1/ Why do i have to pass any database credentials since there is no direct connection between the CrReport or the Dataset with the Database?

2/ How do i set the credential of a Dataset (or crystal report) using a ConnectionInfo object (in my case)?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900