?
Solved

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

Posted on 2011-02-17
2
Medium Priority
?
842 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

771 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