473,883 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change Database at Runtime for Crystal Report

I'm developing an application in VS.Net 2003 using C#, which uses Crystal
Reports.

When creating each report, crystal asks where the database to use is, so I
specify our SQL server using the ADO option. The problem is that these
database settings seem to get compiled into the report, so when we take the
application to our client it won't work on their systems.

Before running each report I run some code which is ment to reset the
database information to the correct settings (used by our client) for each
table. The problem is that the report has an SQL Query Command embedded in
it (this query unions two select statements), which when in design view in
crystal it just looks like another database table. The code which runs seems
to update the database information, but cannot update the location setting
for the query and therefore when the report is run, it will keep trying to
look at the SQL Server we used for development.

The Crystal Help suggests something like:
TableLogOnInfo logOnInfo = new TableLogOnInfo( );
// Loop through every table in the report.
for(int i=0;i<report.Da tabase.Tables.C ount;i++)
{
// Set the connection information for the current table.
logOnInfo.Conne ctionInfo.Serve rName = DataSource;
logOnInfo.Conne ctionInfo.Datab aseName = DatabaseName;
logOnInfo.Conne ctionInfo.UserI D = Username;
logOnInfo.Conne ctionInfo.Passw ord = Password;
report.Database .Tables[i].ApplyLogOnInfo (logOnInfo);
}

This doesn't work unless you add:
report.Database .Tables[i].Location = DatabaseName.db o.TableName

The problem with this is that when it gets to the table called "Command"
which is the SQL Query, Crystal throws an exception because it decides that
"Command" is not a valid table in the specified database.

If you get the code to ignore the "Command" query/table then the report will
continue trying to access our SQL Server for this one query and not the
other one specified.

I've made sure that the SQL Query doesn't have any occurances of
"dbo.tablen ame" and instead just has "tablename" . Both methods fail.

Does anyone know how to update the connection details for a SQL Command in
Crystal?

Thanks,
Grant
Nov 22 '05 #1
4 12935
> I'm developing an application in VS.Net 2003 using C#, which uses Crystal
Reports.
Poor soul - you have my sympathies. :)

When creating each report, crystal asks where the database to use is, so I
specify our SQL server using the ADO option. The problem is that these
database settings seem to get compiled into the report, so when we take the application to our client it won't work on their systems.


About 18months ago, I discovered that this was happening to our reports
also, in v9 evaluation and the version that ships with VS.NET. Everything
changes except the database when you set the connection details at runtime.
If you are using SQL Server you can run a trace and notice that it tries to
access the original database that the report was developed against,
regardless of your code. We develop against what is essentially an
arbitrary named database, so this is a major problem for us too.
Nov 22 '05 #2
> When creating each report, crystal asks where the database to use is, so I
specify our SQL server using the ADO option. The problem is that these
database settings seem to get compiled into the report, so when we take the application to our client it won't work on their systems.


(Whoops - sent the message before I finished! Wrong key combo..)

I filed a bug report to Crystal/Seagate over a year ago about the fact the
database does not reflect changes at runtime, but the last evaluation I
downloaded still hadn't addressed this problem. I also got into
conversations with other users facing this problem who also reported or had
no help from Crystal support. All in all, it sucks. Version 8 doesn't
suffer from this, so we use that through COM.

I don't think it helps that it manifests itself as an addressed issue
(completely unrelated) that they provide a "fix" for. So while it doesn't
exactly help you out, at least you know you're not alone and (as far as I'm
willing to guess) it's not your fault :)

(btw, we use ODBC access to our database[s] not ADO directly, but the
problem seems to persist)

K.
Nov 22 '05 #3
Hello,

Thanks for the reply, its good to know its not just my code. I guess I'll
have to work around it somehow.

One question, is it just the Database Name that cannot be changed at runtime
but the Database Server, Username and Password can be changed?
Because if this is the case then I can probably live with it, although it
will make testing the software against our development database and our
clients database a little more annoying.

Thanks for the help,
Grant
"Kev Sherratt" <k.********@lan caster.ac.uk> wrote in message
news:c9******** **@alliance.lan cs.ac.uk...
When creating each report, crystal asks where the database to use is, so I specify our SQL server using the ADO option. The problem is that these
database settings seem to get compiled into the report, so when we take the
application to our client it won't work on their systems.


(Whoops - sent the message before I finished! Wrong key combo..)

I filed a bug report to Crystal/Seagate over a year ago about the fact the
database does not reflect changes at runtime, but the last evaluation I
downloaded still hadn't addressed this problem. I also got into
conversations with other users facing this problem who also reported or

had no help from Crystal support. All in all, it sucks. Version 8 doesn't
suffer from this, so we use that through COM.

I don't think it helps that it manifests itself as an addressed issue
(completely unrelated) that they provide a "fix" for. So while it doesn't
exactly help you out, at least you know you're not alone and (as far as I'm willing to guess) it's not your fault :)

(btw, we use ODBC access to our database[s] not ADO directly, but the
problem seems to persist)

K.

Nov 22 '05 #4
> One question, is it just the Database Name that cannot be changed at
runtime
but the Database Server, Username and Password can be changed?
Because if this is the case then I can probably live with it, although it
will make testing the software against our development database and our
clients database a little more annoying.


From what I've experienced, yes, it's just the database name (this is with
ODBC and a minor ADO testing with SQL Server.) But of course, your mileage
may vary and it'd be best to make sure this is the case with you too,
obviously.

Best of luck.
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8382
by: munish | last post by:
I am using pull model in crystal reports.For simplicity I m using only one table in SQL Server. I have tried following code to change my database: ConnectionInfo ci = new ConnectionInfo(); ci.ServerName = Changed_SERVER_NAME; ci.DatabaseName = Changed_DATABASE_NAME; ci.UserID = Changed_DATABASE_USER_NAME; ci.Password = Changed_DATABASE_PASSWORD; TableLogOnInfo li = new TableLogOnInfo(); li.ConnectionInfo = ci;
4
1130
by: Grant Stanley | last post by:
I'm developing an application in VS.Net 2003 using C#, which uses Crystal Reports. When creating each report, crystal asks where the database to use is, so I specify our SQL server using the ADO option. The problem is that these database settings seem to get compiled into the report, so when we take the application to our client it won't work on their systems. Before running each report I run some code which is ment to reset the...
0
1213
by: Arif | last post by:
MY crystal report is using Access database. At design time i set file path for report. But i want that i can change this path at runtime so that my report can connect to the same database on anypath .i.e. database file path should not be fixed. How can i do that? Please help. Arif.
7
11258
by: Henry | last post by:
I am writing a Windows forms VB.Net/MS SQL application via VS 2003 that utilizes Crystal Reports. I want to be able to dynamically set the report data source at run time. I'm trying to change the the reports "integrated security" from TRUE to FALSE via the "Set Location" dialog in the report designer with no success. It is not intuitive (at least not to me.) I get the following error:
0
1878
by: Ray | last post by:
Dear all, Now I am using the report document in vb.net to call the crystal report and I will set the database information in the report document. The code is as follow: ... ReportTemp.Load(_reportname) For Each table In ReportTemp.Database.Tables logoninfo = table.LogOnInfo With logoninfo.ConnectionInfo .ServerName = "Server"
6
4688
by: pearsons_11114 | last post by:
Changing connection info at run time with Crystal does not seem to work as advertised. I've tried the code in the documentation and the code that's been posted in the crystal group numerous times by Shariq. Here are my particulars: ..NET 1.1, SP1 Crystal Dev. 10 SQL Server Report has one table (a command), and no subreports. As long as I pass in a server name of "(local)", it works fine, no login
1
16433
by: ngpost1 | last post by:
I have a Crystal Reports.Net report being generated from my C# application. I would like to change the background color of the details section (not the text mind you) of the report on certain conditions. For example if the value of the 'Meeting Number' is greater than 100 the background color of the details section will be light yellow, otherwise it will be white. There will be multiple records in this reports so one (or a few) detail...
4
1961
by: Rodo | last post by:
Hi all, I'm new to this whole thing. I have a bunch of text files that are created by a software at work that keeps info one of our products. Each unit being calibrated gets a "record" (track by serial number) which is a text file with data. The data is almost all the same format. There is header info about the customer, then some more specs about the product then between 5 to 14 rows of calibration data. The software that controls...
0
1061
by: hemu4hemang | last post by:
Hi Friends I m working on one application in Vb.net and Sql server and crystal report 9.0. This application works fine and all reports are open successfully. I assign servername and database name at runtime in my code while opening reports. But whenever i change my server some reports are not open. If i open these reports manually from crystal report and update servername and database name...
7
10118
OuTCasT
by: OuTCasT | last post by:
I know how to change the database and sqlserver for a crystal report Dim report As New ReportDocument Dim connection As IConnectionInfo Dim oldServerName As String = ".\SQLEXPRESS" Dim oldDatabaseName As String = oldDatabaseName Dim newServerName As String = newServerName Dim newDatabaseName As String = newDatabaseName Dim UserID As String = "" Dim Password As String = ""
0
9793
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11151
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10858
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10420
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9582
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7974
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5804
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5996
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4225
muto222
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.