Open Crystal Report

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I have a regular C# form with a button on it. I want to click the
button and open the report.

What code do I need to open the report?

Thanks-in-advance.

Bob
 
Hi,
The following code snippet gets a report name and absolute filepath from a
datagrid and displays it the Crystal Report Viewer object on the form.
HTH
CrystalDecisions.Shared.TableLogOnInfo t;

t = new CrystalDecisions.Shared.TableLogOnInfo();


t.ConnectionInfo.UserID = "MyUser";

t.ConnectionInfo.Password = "MyPassword";

string sReportFile = mstrReportPath +
dgReports.SelectedRows[0].Cells[1].Value.ToString();//Full path

string sReport = dgReports.SelectedRows[0].Cells[1].Value.ToString();


ReportDocument r;

CrystalReportParameters.ICrystalParameters c = new
CrystalReportParameters.clsMain() ;

r = c.DisplayParameters(sReport, sReportFile);



if(r!=null)

{

crv.LogOnInfo = new CrystalDecisions.Shared.TableLogOnInfos();//crv is the
CrystalReportViewer object

crv.LogOnInfo.Add(t);

crv.ReportSource = r;

}
 
All I want is the code that runs on the on_click event of my command
button...I already have the report..



Hi,
The following code snippet gets a report name and absolute filepath from a
datagrid and displays it the Crystal Report Viewer object on the form.
HTH
CrystalDecisions.Shared.TableLogOnInfo t;

t = new CrystalDecisions.Shared.TableLogOnInfo();


t.ConnectionInfo.UserID = "MyUser";

t.ConnectionInfo.Password = "MyPassword";

string sReportFile = mstrReportPath +
dgReports.SelectedRows[0].Cells[1].Value.ToString();//Full path

string sReport = dgReports.SelectedRows[0].Cells[1].Value.ToString();


ReportDocument r;

CrystalReportParameters.ICrystalParameters c = new
CrystalReportParameters.clsMain() ;

r = c.DisplayParameters(sReport, sReportFile);



if(r!=null)

{

crv.LogOnInfo = new CrystalDecisions.Shared.TableLogOnInfos();//crv is the
CrystalReportViewer object

crv.LogOnInfo.Add(t);

crv.ReportSource = r;

}

Bob said:
I have a regular C# form with a button on it. I want to click the
button and open the report.

What code do I need to open the report?

Thanks-in-advance.

Bob
 

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

Back
Top