473,385 Members | 2,162 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,385 software developers and data experts.

C# App - Changing Database location on runtime

I have a Crystal Report that I need to change the database location during runtime. Does anyone know how to do this? I have tried different ways and they all have errors. Here is a copy of my code:

ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables crTables;
Table crTable;
TableLogOnInfo crTableLogOnInfo;

crConnectionInfo.ServerName = "ServeName";
crConnectionInfo.DatabaseName = "DatabaseName";
crConnectionInfo.UserID = "UserID";
crConnectionInfo.Password = "Password";

for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables [i];
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);

crTable.Location = "DatabaseName.xml" + crTable.Name;
}
Oct 25 '07 #1
1 1913
r035198x
13,262 8TB
I have a Crystal Report that I need to change the database location during runtime. Does anyone know how to do this? I have tried different ways and they all have errors. Here is a copy of my code:

ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables crTables;
Table crTable;
TableLogOnInfo crTableLogOnInfo;

crConnectionInfo.ServerName = "ServeName";
crConnectionInfo.DatabaseName = "DatabaseName";
crConnectionInfo.UserID = "UserID";
crConnectionInfo.Password = "Password";

for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables [i];
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);

crTable.Location = "DatabaseName.xml" + crTable.Name;
}
When do you want to change the database location? Do you mean that you have two different databases and you want to switch from accessing one to accessing the other during runtime? Why not create a new connection then with connection settings for the second database?
Oct 25 '07 #2

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

Similar topics

1
by: Steven Buroff | last post by:
Is there any way to get MySQL to create the directory for a new database in a specified directory instead of its "data" directory?
2
by: amnésia | last post by:
Hi there. I have to change the drive letter where SQL server have his datfiles (master included). If I do that, ob the SQL fail to start, becouse it's unable to find the master datfiles. Is it...
1
by: Sean | last post by:
i am writing a class that visual demonstrates the result of changing the quality of a jpeg. the intention is to do this by saving the file and a selected quality, then reloading it to get an idea of...
7
by: Phin | last post by:
I need your HELP! I've seen all the posts on using Crystal Reports within vs.net (vb.net) and changing a SQL query at runtime. When I tried to pass in a dataset into the crystal report at...
7
by: Luis Mendes | last post by:
Hello, I've a application in VB.NET that uses a connection to a Access data base stored in my Hard Drive. How can I change the location of the database (To a network) and change the conection...
2
by: inzo | last post by:
Hello all. I built a distributed application that is used for message transferring to different locations. The basic flow is as follows... 1. User logs in to app - app queries central database...
3
by: Richard Hollenbeck | last post by:
Hello, I just moved my main database and the backend database to a better location and changed the name. But now I can't seem to get Access to recognize the new location and name. I tried using...
0
by: michael ngong | last post by:
pramod@rtimes.com (Pramod Ramachandran) wrote in message news:<6616e304.0306240122.4dd3ecd5@posting.google.com>... Permit me start with the second question. It would be easier to be more...
7
by: franc sutherland | last post by:
Hi everyone, I am using Access 2003. I have a database with a table in it which is linked to an excel spreadsheet. When I install the database on someone else's system, the pathname to the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
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...

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.