Solved

ADO OLE Connection with ASP C#.NET for Crystal 2008

Posted on 2011-02-17
2
837 Views
Last Modified: 2012-05-11
We have been using the ODBC connection to use the Crystal Viewer in our .NET programs,  specfically C#.NET (Aspx).  Does anyone had the integrated security connection to the Crystal Report written in C#.  At this point I have this.... But I keep getting failure to login to the database on the SQL connection, which is ADO OLE.  I cannot seem to find an example of the code for this type of connection to Crystal in C#.

Thank you in Advance!!

 // Connect to Crystal Report
        ConnectionInfo connectionInfo = new ConnectionInfo();
        connectionInfo.ServerName = "ServerName";
        connectionInfo.DatabaseName = "DatabaseName";
        //Using windows authenication
        // connectionInfo.userid = XXXXX; Don't use
        // connectionInfo.password = XXXXX; Don't use
        SetDBLogonForReport(connectionInfo);

        crystalReportViewer.ReportSource = SecurityIntakeReport;
        Session["SecurityIntakeReport"] = SecurityIntakeReport;
0
Comment
Question by:kimmie8000
  • 2
2 Comments
 

Accepted Solution

by:
kimmie8000 earned 0 total points
ID: 34920016
I figured this out on my own.

This is how you would want to do this without an ODBC!

How to use OLE DB ADO with embedded Crystal 2008 Report?

 

In the Crystal 2008 report, you go into the menu option “Database”.  Click on Database.  There are other ways to get there, but this is just for example.  

 

It will give you options.

 

Database Expert

Set Database Location

Log on or off server

 

Verify Database

Show SQL Query

Perform groupings on server

Select distinct records

 

_---------------------------------------------------------------------

 

You will want to click Set Database Location.  

 

The provider on the database location must be sqloledb, not sqlncli for ADO to work on servers.

 

To change this, do the following:

1.  Select Set Database Location

 

2.  Expanded the + sign on the Properties option below the server name.  You will need to do this for the “Subreports”, as well.  On the Subreports, you will click the + sign on the server name first.  Then you will the + on the Properties.  At this point, you can look at the connections properties.

 

Please note that that the Database Type: OLE DB (ADO), the provider is SQLOLEDB.

 

We are using integrated security, so this is set to, True in the report, as well.  

 

Leave this rest of the “Properties” as default.

If any of these properties are not correct, all you have to do I highlight the property and right click to edit the property.  

You don’t have to do a universal database location change, which can cause problems if you are jumping from server to server.  This is much easier.

Now instead of putting the ODBC connection for the report connection in the .cs code, you can place it in the web.config file for the C#.NET code, which will look like this.

// Connect to Crystal Report place directly in C# code.

        ConnectionInfo connectionInfo = new ConnectionInfo();

        connectionInfo.ServerName = "Your Server Name";

        connectionInfo.DatabaseName = "Your Database Name";

        connectionInfo.IntegratedSecurity = true;

        //Using windows authenication

        // connectionInfo.userid = XXXXX;

        // connectionInfo.password = XXXXX;

        SetDBLogonForReport(connectionInfo);

 

Now, we can do a connection information string in the web.config file.  

This way if we need to change the server name it is not a hassle.  However, you will still need to change the server name (connection) on the report(s), or the report(s) will fail to load properly.  

The web.config file will look like this for the connection information.

Now you do not need an extra ODBC connection to the server!


Web.Config

Add the following to the web.config so that then you can change the database in the config, and not have to recompile the code, if these values change.

<!-- connection string -->

              <add key="OSFServerName" value="xxx-xxx-xxxx" />

              <add key="OSFDBaseName" value="DatabaseName" />

// C# programming code.

             

  ConnectionInfo connectionInfo = new ConnectionInfo();

        connectionInfo.ServerName = WebConfigurationManager.AppSettings["OSFServerName"];

        connectionInfo.DatabaseName = WebConfigurationManager.AppSettings["OSFDBaseName"];

        SetDBLogonForReport(connectionInfo);

 

Summary

This was stumbled on by accident, because we had been doing OLE DB (ADO) for Business objects.  In my rush to get a report for a new program.  I accidently clicked the ADO instead of the ODBC.  

This technique eliminated the extra step of creating an ODBC connection every time we create a Crystal report that is embedded in the C#.NET/ASPX.

The things that have to be "so" in the report Database Expert in Crystal 2008!

provider = sqloledb

Datasoure = ServerName

IntialCatalog = DatabaseName

IntegratedSecurity = true

I hope this helps..... You will get the generic Load Report Failed, if this is done incorrectly.  A few hours of that will drive you insane.  

0
 

Author Closing Comment

by:kimmie8000
ID: 34920027
I was able to figure this out on my own.  I thought I would share with the rest of the EE commnunity being that I been with you guys since your web site went live.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now