on 04-30-2016 4:20 PM
Hi,
My Application uses an MS ACCESS Database that is stored in the Debug Directory.
Whilst on the development machine, the crystal reports behave as required.
When I deploy the application onto a workstation, the application works fine, but crystal reports is still pointing the location as on the development machine.
After copying all the reports to the debug directory, most errors are eliminated however the connection to database is still causing a problem.
I have tried this without success:
crConnectionInfo.AllowCustomConnection = true;
string rptPath = Application.StartupPath;
crConnectionInfo.DatabaseName = rptPath + @"\POSRSI.mdb";
crConnectionInfo.UserID = "";
crConnectionInfo.Password = "";
How can I programmatically, change the crystal reports connection path?
Your help is appreciated.
That should work....
Try using this:
CrystalDecisions.Shared.TableLogOnInfo tLogonInfo;
try
{
foreach (CrystalDecisions.CrystalReports.Engine.Table rptTable in rpt.Database.Tables)
{
tLogonInfo = rptTable.LogOnInfo;
tLogonInfo.ConnectionInfo.ServerName = "";
tLogonInfo.ConnectionInfo.DatabaseName = D:\Atest\199019\YourMDB.mdb
tLogonInfo.ConnectionInfo.UserID = "";
tLogonInfo.ConnectionInfo.Password = "";
tLogonInfo.TableName = rptTable.Name;
dtStart = DateTime.Now;
try
{
rptTable.ApplyLogOnInfo(tLogonInfo);
}
catch (Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message);
//return;
}
And don't forget to do the same for subreport connection info.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.