473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Crystal reports

OuTCasT
374 256MB
i have a payroll program that can start new companies, a company has its own database. they will always be the same tables etc inside all the databases/companies.

now i have done a report in crystal reports. now i want to use jst that report for all the companies that will be created.
I have changed the servername and databasename at runtime but it still brings back the information from the company that i designed the report on....
is there something that im missing.

Expand|Select|Wrap|Line Numbers
  1. Dim report As New ReportDocument
  2.         Dim connection As IConnectionInfo
  3.         Dim oldServerName As String = ""
  4.         Dim oldDatabaseName As String = ""
  5.         Dim newServerName As String = TextBox1.Text
  6.         Dim newDatabaseName As String = "dude"
  7.         Dim UserID As String = ""
  8.         Dim Password As String = ""
  9.  
  10.  
  11.         report.Load("C:\report2.rpt")
  12.         CrystalReportViewer1.ReportSource = report
  13.  
  14.         'Change the server name and database in main report
  15.         For Each connection In report.DataSourceConnections
  16.             If (String.Compare(connection.ServerName, oldServerName, True) = 0 _
  17.                And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then
  18.                 'SetConnection can also be used to set new logon and new database table
  19.                 report.DataSourceConnections(oldDatabaseName, oldDatabaseName).SetConnection(newServerName, newDatabaseName, UserID, Password)
  20.             End If
  21.         Next
  22.         'Change the server name and database subreports
  23.         Dim subreport As ReportDocument
  24.         For Each subreport In report.Subreports
  25.             For Each connection In subreport.DataSourceConnections
  26.                 If (String.Compare(connection.ServerName, oldServerName, True) = 0 _
  27.                    And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then
  28.                     subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection(newServerName, newDatabaseName, UserID, Password)
  29.                 End If
  30.             Next
  31.         Next
Jun 30 '08 #1
1 1457
asmvax
1
I did something like this:

private report2 As ReportDocument

in load:

report2 = New ReportDocument
report2.Load("report1.rpt")
report2.SetDatabaseLogon(UserName, UserPassword)

report2.Database.Tables(0).SetDataSource(datatable 1)
report2.Refresh()
cristalViewer1.ReportSource = report2
Jul 21 '08 #2

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

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
5
by: BStorm | last post by:
I have a transaction log file where the DataSet table's Description column is actually delimited into "subcolumns" based upon the transaction id. I would like to parse these into separate fields...
3
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
0
by: Robert Warnestam | last post by:
Hello, I have some problems deploying Crystal Reports. I'm using Visual Studio 2005 Beta 1. In this version Crystal Reports (9.7.3500.0) is included. I created a small test application...
3
by: VMI | last post by:
I know this may not be the best NG for this, but I feel you guys know more about this than any of the other NGs. I need to build several simple reports (over 50 of them and they get their data...
1
by: Lyners | last post by:
Hello all, I have created an ASP.NET website that uses Crystal Reports that works on the localhost (my PC), but when I copy it to the server it does not. The problem is...
2
by: =?Utf-8?B?Um9zcyBNYXNvbg==?= | last post by:
Hi I am interested in using crystal reports for the first time but have a few questions that someone maybe able to help with before I get started. The background to my query is that a client is...
3
by: Miro | last post by:
Hi, Just wondering what a good book is on visual studios 2008 ( or 2005 if no 2008 ) that teaches you how to properly use crystal reports with it. Or im assuming that as long as I can create a...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.