473,473 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cannot load crystalreportviewer even with good connection information.

1 New Member
This is my first attempt at using a CrystalReportViewer control, so please forgive me if I'm making some obvious mistake.

Here are the steps I'm taking to try to populate it with a very simple report (just a couple of fields dragged over). Some of this may be overkill or unnecessary but I've been tearing my hair out trying to figure out what the missing bit of magic is.

1. new the ReportDocument object
2. Call ReportDocument.Load( reportpath.rpt)
3. Iterate through each IConnectionInfo object in ReportDocument.DataSourceConnections

3.1 call IConnectionInfo.SetConnection( serverName, databaseInstanceName, true) for each one

4. Iterate through each Table object in ReportDocument.Database.Tables

4.1 Create a new ConnectionInfo object and set .ServerName, .DatabaseName, and .IntegratedSecurity

4.2 Assign that object to Table.LogOnInfo.ConnectionInfo

4.3 Call Table.ApplyLogOnInfo( Table.LogOnInfo );

4.4 Assign Table.Location = database + ".dbo." + toApplyTo.Location.Substring( toApplyTo.Location.LastIndexOf( "." ) + 1 );

4.5 Call Table.TestConnectivity *NOTE: THIS NEVER FAILS*

5. Repeat the process for any subreports ( there are none in my test reports)
6. Call ReportDocument.VerifyDatabase() *NOTE: THIS NEVER FAILS*
7. Assign CrystalReportViewer.ReportSource = ReportDocument



The control loads with no data, just as I see it in the designer.

What am I doing wrong?

My code (_workingDb is my database wrapper object in other parts of the application, but here I'm just using it as a container for the relevant information):

Expand|Select|Wrap|Line Numbers
  1.  
  2.         private void FormReport_Load( object sender, EventArgs e )
  3.         {
  4.             ReportDocument toShow = new ReportDocument();
  5.             toShow.Load( _reportPath );
  6.  
  7.  
  8.             this.Text = toShow.Name;
  9.  
  10.             SetConnectionInfo( toShow, _workingDb.ServerName, _workingDb.DatabaseName );
  11.  
  12.             toShow.VerifyDatabase();
  13.  
  14.             crystalReportViewerMain.ReportSource = toShow;
  15.  
  16.         }
  17.  
  18.  
  19.         private void SetConnectionInfo( ReportDocument toShow, string server, string database )
  20.         {
  21.             foreach( IConnectionInfo connInfo in toShow.DataSourceConnections )
  22.             {
  23.                 connInfo.SetConnection( server, database, true );
  24.             }
  25.  
  26.             foreach( Table toApplyTo in toShow.Database.Tables )
  27.             {
  28.  
  29.                 TableLogOnInfo toAlter = toApplyTo.LogOnInfo;
  30.  
  31.  
  32.                 ConnectionInfo newConnection = new ConnectionInfo();
  33.                 //don't know if this has any impact, fails either way
  34.                 //newConnection.Type = ConnectionInfoType.SQL;
  35.                 newConnection.ServerName = server;
  36.                 newConnection.DatabaseName = database;
  37.                 newConnection.IntegratedSecurity = true;
  38.                 //not sure what this does...seems undocumented
  39.                 //toAlter.ConnectionInfo.AllowCustomConnection = true;
  40.  
  41.                 toAlter.ConnectionInfo = newConnection;
  42.  
  43.  
  44.                 toApplyTo.ApplyLogOnInfo( toAlter );
  45.  
  46.                 toApplyTo.Location = database + ".dbo." + toApplyTo.Location.Substring( toApplyTo.Location.LastIndexOf( "." ) + 1 );
  47.                 if( !toApplyTo.TestConnectivity() )
  48.                 {
  49.                     MessageBox.Show( "ERROR: could not establish connection to table (" + toApplyTo.Name + ")." );
  50.                 }
  51.  
  52.             }
  53.  
  54.             foreach( ReportDocument subReport in toShow.Subreports )
  55.             {
  56.                 SetConnectionInfo( subReport, server, database );
  57.             }
  58.         }
  59.  
  60. //DEBUGGING SIMPLE STUFF
  61.         private void crystalReportViewerMain_DoubleClick( object sender, EventArgs e )
  62.         {
  63.             crystalReportViewer.Focus();
  64.             crystalReportViewer.Refresh();
  65.             int pageNum = crystalReportViewer.GetCurrentPageNumber();
  66.             crystalReportViewer.Refresh();
  67.             crystalReportViewer.InitReportViewer();
  68.             crystalReportViewer.Refresh();
  69.             crystalReportViewer.PerformAutoScale();
  70.             crystalReportViewer.Refresh();
  71.             crystalReportViewer.PerformLayout();
  72.             crystalReportViewer.Refresh();
  73.             crystalReportViewer.Refresh();
  74.             crystalReportViewer.Refresh();
  75.             crystalReportViewer.RefreshReport();
  76.             crystalReportViewer.Refresh();
  77.             crystalReportViewer.Show();
  78.             crystalReportViewer.Refresh();
  79.             crystalReportViewer.ShowFirstPage();
  80.             crystalReportViewer.Refresh();
  81.             crystalReportViewer.ShowNextPage();
  82.             crystalReportViewer.Refresh();
  83.             crystalReportViewer.ShowLastPage();
  84.             crystalReportViewer.Refresh();
  85.             crystalReportViewer.Update();
  86.             crystalReportViewer.Refresh();
  87.  
  88.         }
  89.  

Thanks,

-David
Oct 20 '11 #1
0 1512

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: lithne | last post by:
Hi, when I try to open phpMyAdmin administration page I got this error: 'Cannot load mysql extension, please check your PHP configuration' I cannot sort out what's the source of the problem,...
3
by: Oren | last post by:
Hi, Is there a way to hide the connection information of linked SQL Server tables from users? It's easy to open a system table and find the connection info, and if the username and password are...
4
by: Sylvain | last post by:
Hi ! Here's my problem: I have actually an asp web site which use the global.asa file to connect to the database but for security reason, I want to put username and password information (or...
2
by: A. User | last post by:
Hello, Where does the ODBC Data Source Admin tool store the connection information for User, System or File DSNs? A coworker created/used several ODBC connections on his machine, we backed up...
1
by: Jon | last post by:
Hello all - just a spot of advice required. I'm wanting to write a number of data layers that will be used to carry out the typical CRUD operations against a database - so 1 database will be...
2
by: jobrien9796 | last post by:
I'm using Access 2002 with linked tables to access an SQL Server database. Authentication is done using Windows authentication (not user id+password). As far as I can tell, when the table is...
1
by: Serenityquinn15 | last post by:
Hi! "Cannot Start your Application, the workgroup information file is missing or opened exclusively by another user" this is the error i got when i run my system. i'm using adodc connection to...
1
by: kw.housing | last post by:
I have all the library already in path: $ ls -l /opt/IBM/db2/lib64 | grep libdb2o -r-xr-xr-x 1 bin bin 7757295 Jul 12 2006 libdb2osse.a* -r--r--r-- 1 bin bin ...
4
by: ValValVal | last post by:
Hi! Please help with following question, this is really something I have not a clue why this is happening. I want to display BufferedImage in my JFrame. Now I need to load images first from disk....
0
by: Ammarqqqq | last post by:
I am getting this error: Cannot Load View State. : Gird- DetialsViews Control + Radio ButtonLists Whenever I update the records in edit(update) mode. The details goes back to the Read Only Mode...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.