Skip to Content
author's profile photo Former Member
Former Member

Using Crystal Report 2008 in VB.net 2005

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 13, 2009 at 08:34 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 17, 2009 at 08:08 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.