cancel
Showing results for 
Search instead for 
Did you mean: 

Using Crystal Report 2008 in VB.net 2005

Former Member
0 Kudos

I have created a report in CR Xi R2, and now I have converted it to CR 2008. What is the code that I need to use to log into a SQL 2005 database to display this report in VB.NET 2005? I have already placed the the CrystalViewer on a form, but so far everything that I have found, I receive a logon failure. Also the Crystal Report 2008 developer version has been installed on a clean box. (No other versions of Crystal Reports has ever been installed on it. Thank you for your help.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You could refer to [these samples|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b07a158a-b766-2b10-a79e-bfc6d19c6b99] in case you face any issues accessing crystal reports from the .NET application

Former Member
0 Kudos

Hi,

I would like you to know the code of the logon based on the object models-

If you are using the ConnectionInfo then use the below code:-


//For web application

ConnectionInfo crConnection = new ConnectionInfo();

// Connection Information

crConnection.ServerName="D-2818-W2K";
crConnection.DatabaseName="Northwind";
crConnection.UserID="sa";
crConnection.Password="sa";


crReport.Load(Server.MapPath("CrystalReport1.rpt"));


Tables crTables=crReport.Database.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
	{
		TableLogOnInfo crTLOI = crTable.LogOnInfo;
		crTLOI.ConnectionInfo=crConnection;
		crTable.ApplyLogOnInfo(crTLOI);
		crTable.Location=crTable.Location;// for multiple table selection
	}

CrystalReportViewer1.ReportSource=crReport;
====================================================================================

//For desktop application

ConnectionInfo crConnection = new ConnectionInfo();

// Connection Information

crConnection.ServerName="D-2818-W2K";
crConnection.DatabaseName="Northwind";
crConnection.UserID="sa";
crConnection.Password="sa";


crReport.Load(Application.StartupPath + "//CrystalReport1.rpt");


Tables crTables=crReport.Database.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
	{
		TableLogOnInfo crTLOI = crTable.LogOnInfo;
		crTLOI.ConnectionInfo=crConnection;
		crTable.ApplyLogOnInfo(crTLOI);
		crTable.Location=crTable.Location;// for multiple table selection
	}

CrystalReportViewer1.ReportSource=crReport;

=====================================================================================







If using ReportDocument object model

//For web application

ReportDocument crReport= new ReportDocument();
crReport.Load(Server.MapPath("CrystalReport1.rpt"));
crReport.SetDatabaseLogon("sa","sa");
CrystalReportViewer1.ReportSource =crReport;

=====================================================================================

//For desktop application

ReportDocument crReport= new ReportDocument();
crReport.Load(Application.StartupPath + "//CrystalReport1.rpt");
crReport.SetDatabaseLogon("sa","sa");
CrystalReportViewer1.ReportSource =crReport;

Regards

Amit